Indent
Two spaces is the default and what most JavaScript style guides use. Four and tab are there for projects that already use them — match your codebase rather than your preference.
Paste minified, one-line or badly indented JavaScript and get it back readable. Modern syntax is handled, and nothing you paste leaves your browser.
Beautifying reverses a build. Minified bundles, one-line handlers, code pasted out of a browser console — all of it goes in shapeless and comes back with one statement per line and a fresh indent at every block.
function shipping(n){if(n>=75){return 0}else if(n>=30){return 3.95}return 5.95}
function shipping(n) {
if (n >= 75) {
return 0
} else if (n >= 30) {
return 3.95
}
return 5.95
}
Modern syntax is handled: arrow functions, classes and private #fields, optional chaining,
nullish coalescing, template literals, async and await, generators, and ES module import and export.
Two spaces is the default and what most JavaScript style guides use. Four and tab are there for projects that already use them — match your codebase rather than your preference.
On by default, capped at one. Blank lines are how a person groups related statements, and stripping them turns a readable function into a wall.
Allman style. Off by default, because JavaScript puts the opening brace on the same line — and with
return it is not only convention: a brace on the next line triggers ASI and returns
undefined.
Reports unbalanced brackets, unterminated strings and unclosed block comments, each with a line number, and formats the result alongside.
It is a structural check, not a linter and not a parser. It reads the file the way the minifier does — tracking strings, template literals, regular expressions and comments — and reports the three faults that make a file fail to load at all:
{, ( and [ that is
never closed, reported at the line it opened on rather than at the end of the file.{ closed by a ], naming both lines./* block comment with no end — which silently swallows everything after it.For real static analysis — unused variables, shadowed names, accidental globals, promises you forgot to await — you want ESLint. It runs in your editor and knows what your code means, which no browser-side checker can.
Beautifying a production bundle makes it readable, and it will not make it comprehensible. Minifiers rename local variables to single letters, and that cannot be undone — the original names are gone from the file.
What survives: string literals, property names on objects you did not create, imported module names, and the structure of the code. That is usually enough to work out what a function does, which is what you were after.
If a source map is published alongside the bundle — look for a //# sourceMappingURL comment
at the end — your browser's devtools will show you the original source with real names, which is far better
than anything a beautifier can reconstruct.
For code you work on regularly, this should happen on save and never be a decision anyone makes.
npm install --save-dev prettier
npx prettier --write "src/**/*.js"
npx prettier --check "src/**/*.js" # fails the build if anything is unformatted
Prettier is the standard across the JavaScript ecosystem, and it is better than this page for code you own: it understands JSX, TypeScript and your framework's templates, and it is configured per project so everyone's output matches.
This page is for the cases with no project — a snippet from a colleague, a file you are inspecting on someone else's machine, a bundle you want to read, or code you would rather not paste into a website that uploads it.
Beautifying JavaScript properly means understanding the grammar, and the hardest part is the ambiguity of
/ — it starts a regular expression in one context and divides in another, and telling them apart
needs to know what came before. Getting every case right takes years of bug reports.
So the beautifier here is js-beautify, which has had those years and is MIT licensed. It is a file your browser downloads once and then runs locally — nothing is sent anywhere, exactly as with every other tool on this site. The minifier on the minifier page is written here, and that page explains why it works the way it does.
No. The beautifier is a JavaScript file your browser downloads once and then runs on your own device. Open the Network tab and press Format — no request is made. That matters for JavaScript, which routinely contains API keys, internal endpoints and business logic.
No, and nothing can. Minifiers rename local variables to single letters and the originals are not in the file any more. Beautifying restores the structure and the whitespace, which is enough to follow what the code does. If a source map is published you will get the real names in devtools.
Partly. Plain type annotations usually survive, but decorators, generics and some newer syntax can confuse it, because this is a JavaScript beautifier rather than a TypeScript one. Use Prettier for TypeScript — it parses the language properly.
JSX is not reliably handled here. Prettier is the right tool: it understands that the markup inside a component is part of the JavaScript, which a general beautifier does not. If you are converting markup rather than formatting it, the HTML to JSX converter is the page you want.
Because you are adding newlines and leading spaces. That is the point of formatting, and it is why you format the source and minify the build rather than the other way round. The size readout under the panels shows the exact difference.
Check whether the mismatch is inside a string or a template literal that the checker read differently than the engine does. The most common cause is a regular expression containing an unescaped bracket. If you find a case where it is genuinely wrong, send the snippet and it gets fixed.
Strip comments and whitespace, safely.
OpenIndent and structure any HTML file.
OpenTurn minified HTML back into readable code.
OpenPretty-print HTML with the indent you want.
OpenFormat, inspect and repair JSON.
OpenLay out stylesheets with consistent indentation.
OpenLonger reading on formatting, indentation and minification.