JavaScript Beautifier & Minifier

Pretty-print JavaScript or JSON with js-beautify — 1 to 10 space or tab indent, four brace styles, a 20-500 column wrap, JSX — or minify it with Terser.

More options

Make minified JavaScript readable again

Paste minified, obfuscated or badly-formatted JavaScript (or JSON) and it comes back cleanly indented with consistent spacing and line breaks. There is no Format button — the result re-renders as you type. It’s powered by js-beautify, the same formatting engine used by many editors, and starts at 2 spaces, K&R braces and one blank line kept between statements; the brace style, indent, blank lines and space before conditional you pick are remembered on this device until you press Forget saved settings.

Match your project’s style

Indent with 1 to 10 spaces or a tab — eleven widths, and a width the tool does not offer is refused rather than quietly formatted at 2. Pick one of four brace styles: same line (K&R), new line (Allman), end expand, or leave as written, which keeps every brace on the line its author put it on. Decide what happens to blank runs: remove every extra newline, allow 1, 2, 3, 4, 5 or 10 between tokens, or keep them all.

Under More options there is a wrap column and seven checkboxes. Blank or 0 never wraps; a real width has to be between 20 and 500, and anything else — 5, 900, 0.5, a word — is refused with a sentence and no output rather than rounded to a width you did not ask for. The checkboxes are: read JSX/e4x markup, comma-first lists, keep array indentation, break chained methods, space before conditional, unescape \xNN in strings, and JSLint-happy spacing.

Nothing leaves your device

Everything runs in your browser — your code is never uploaded, which makes it safe for proprietary or unreleased scripts. Type it, use the Paste button, or open a file from disk (up to 50,000 bytes to beautify; a larger file is refused with both its size and the limit named), then copy the result or download it — a file you opened comes back under its own name. With every option left alone the tool changes whitespace and line breaks only, so what your code does is untouched. The one option that rewrites anything more is unescape \xNN, which turns printable escapes inside strings back into the characters they stand for and re-escapes a quote or backslash so the string still holds exactly the same text.

Minify

Minify runs your code through Terser instead — the compressor bundlers like Rollup and Vite rely on — to strip comments, collapse whitespace and drop dead code, and shortens local variable names unless you clear Mangle names. It shows the bytes saved, and a syntax error is reported with its line and column instead of broken output. This complements the site’s JSON formatter and HTML formatter.

Frequently asked questions

What does "mangle names" do when minifying?

Mangling renames local variables and function parameters to short single letters (for example, salutationTarget becomes n) to shrink the output further. Top-level and exported names are left intact so your public API keeps working. Turn it off if you need readable variable names.

Does minifying change how my code behaves?

No. Terser only removes things that do not affect execution — whitespace, comments, unreachable code — and safely renames locals. If your input has a syntax error, the tool shows the error instead of producing broken output.

Should I minify if the server already gzips?

Yes, but expect less than the two numbers suggest. Minifying and compressing both exploit redundancy, so the second one finds less after the first has run. Together they still beat either alone.

Can it un-minify JavaScript?

Yes — it re-indents minified code so it’s readable, though it can’t restore original variable names that a minifier shortened.

Does it work on JSON too?

Yes. JSON is valid JavaScript syntax, so pasting a minified JSON blob formats it with proper indentation.

Does beautifying change my code’s behavior?

No. With every option at its default it changes whitespace and line breaks only, and the logic is untouched. One optional checkbox rewrites more than layout — the unescape option, which turns printable hex escapes inside a string back into the characters they stand for and re-escapes a quote or backslash so the string still holds exactly the same text.

How many indent widths can I choose?

Eleven: 1, 2, 3, 4, 5, 6, 7, 8, 9 or 10 spaces, or a tab. The default is 2 spaces, and a width the tool does not offer is refused rather than silently formatted at 2.

Which brace styles are available?

Four: same line (K&R), new line (Allman), end expand, and “leave as written”, which keeps each brace on the line the author put it on instead of moving it.

Can I control the blank lines between statements?

Yes, with eight settings: remove every extra newline, allow 1, 2, 3, 4, 5 or 10 newlines between tokens, or unlimited. The default allows 2, which keeps one blank line.

Can it wrap long lines?

Yes. Set a wrap column under More options: blank or 0 never wraps, and a real width has to be between 20 and 500. A value outside that range, or one that is not a whole number, is refused with a message and no output — nothing is ever wrapped at a width you did not choose.

Does it handle JSX?

Yes, with the “Read JSX / e4x markup” checkbox under More options. Without it, markup like <div className="a">{y}</div> is read as a chain of comparisons rather than as JSX.

Can it unpack or deobfuscate a packed script?

It re-indents obfuscated code so you can read it, but it will not run the script. js-beautify implements packer detection by evaluating the pasted code, and this page will not execute a stranger’s script in your tab. It also cannot restore variable names a minifier shortened.

Can I open a file instead of pasting?

Yes — the Open file button takes .js, .mjs, .cjs, .jsx, .ts, .tsx and .json up to 50,000 bytes to beautify, and a bigger file is refused with both its size and the limit named. The formatted copy downloads under the same file name. The engine is js-beautify’s JavaScript beautifier, so TypeScript-only syntax is formatted as JavaScript rather than parsed as TypeScript.

How much code can it format at once?

Up to 50,000 characters of input; past that it says so instead of freezing the tab. A result over 1,000,000 characters — which unbalanced brackets can produce — is withheld with the same message.