JavaScript Beautifier
Pretty-print minified or messy JavaScript in one click.
JavaScript Beautifier and Pretty Printer
Copied a script from a production bundle, a browser console, or an old code base and can't read it? This JavaScript beautifier reformats it into clean, consistently indented code. It uses Prettier, the formatter behind most modern JavaScript projects, so the result looks exactly like code formatted in VS Code or by a pre-commit hook.
How to pretty print JavaScript
- Paste your code, open a
.jsfile, or click Sample. - Choose 2 spaces, 4 spaces, or tabs and a line width of 80, 100, or 120 characters.
- Decide on semicolons, single or double quotes, and trailing commas.
- Copy or download the formatted JavaScript.
Formatting happens live as you type, and nothing is uploaded: the formatter is loaded into your browser and runs locally.
What the beautifier changes
Prettier parses the code into a syntax tree and prints it again from scratch. Long call chains and argument lists are broken across lines when they exceed the line width, objects and arrays get one entry per line when needed, spacing around operators and keywords is normalized, and quotes become consistent. It never renames variables or changes behaviour — only whitespace, quotes, optional semicolons, and parentheses that do not change the meaning.
Syntax errors are reported
Because the code is parsed first, a missing bracket or a stray comma produces a clear error with the line and column instead of half-formatted output. That makes the tool a quick syntax check as well. For a dedicated report with a code frame, use the JavaScript Validator.
Beautify vs. minify
Beautifying is for humans; minifying is for browsers. Once you have edited the readable version, shrink it again with the JS Minifier. Working with types? The TypeScript Beautifier handles interfaces, generics, and decorators, and the JSX Formatter is tuned for React markup.
Frequently Asked Questions
Can it un-minify code from a bundle?
It restores line breaks and indentation, which makes minified code readable again. It cannot bring back original variable names or comments that a minifier removed — those are gone from the file. Source maps are the only way to recover the original names.
Which JavaScript versions are supported?
Everything Babel can parse: modern ES2025 syntax such as optional chaining, nullish coalescing, class fields and private methods, top-level await, and JSX. Flow and TypeScript have their own parsers on the Babel Formatter and TypeScript Beautifier pages.
Is my code sent to a server?
No. Prettier and its JavaScript parser are downloaded once and run in your browser, so proprietary code never leaves your computer.
Why does the output differ from my editor?
Your project may have a .prettierrc with other settings. Match the indentation, quotes, semicolons, trailing commas, and line width here and the output will be identical.