JavaScript Beautifier
Format and indent minified JavaScript.
How to use JavaScript Beautifier
What this tool does
This tool formats JavaScript. You paste code that is minified, crammed onto a few lines, or inconsistently indented, and it returns the same code rewritten cleanly: one statement per line, blocks indented by the amount you choose, and spacing applied consistently. It is a pretty-printer for JavaScript — the opposite of a minifier. All of the work happens inside your browser, so the code you paste is never uploaded anywhere.
Why you might need it
JavaScript often arrives in a form that is hard to read. Production bundles are minified into dense, near-unreadable lines to shrink download size. Snippets copied from a browser console or a third-party widget come with strange spacing. Code touched by many hands drifts into mixed indentation. The code still runs, but reading or debugging it is slow and mistakes are easy to make. Beautifying restores a predictable, scannable layout so you can follow the control flow, set a breakpoint in the right place, and edit safely.
How to use it
- Paste your JavaScript into the input box — minified, messy, or partial all work.
- Choose your indentation: 2 spaces, 4 spaces, or a tab.
- Click Beautify JavaScript, or press Ctrl/Cmd + Enter.
- Read the formatted result in the output box.
- Copy it with one click and paste it into your editor.
The character counters under each box show the before-and-after size. The formatted version is larger because of the added whitespace — that is expected, and you would minify the code again before shipping it to production.
Common pitfalls
Beautifying is a reformatter, not a debugger. It rewrites the spacing of
whatever you paste; it does not check that the code is correct or warn you about
bugs. If the code misbehaves after formatting, the issue was already there — the
beautifier simply made it visible. Be aware too that beautifying minified code
cannot bring back meaningful variable names: a minifier renames everything to
short tokens like a, b, and c, and that information is gone for good.
Finally, if you paste code that is not valid JavaScript, the formatter does its
best but the output may look off; if something seems wrong, recheck the input.
Tips and advanced use
Set the indentation to match your project so the formatted code drops in without creating a noisy diff — most codebases use two spaces. When you are debugging a minified bundle from a live site, beautify it first so the single-line blob becomes a readable file you can step through. Beautifying is also a good habit before a code review, since a consistently formatted diff is much easier to reason about. And because every operation here is client-side, you can format the source of an internal tool or an unreleased feature without any of it leaving your machine.
Frequently asked questions
Is my JavaScript sent to a server?
Does beautifying change what my code does?
Can it un-minify production JavaScript?
What indentation options are available?
Why does the tool say my input is empty?
Related tools
HTML Minifier
Minify HTML markup for faster pages.
HTML Beautifier
Format and indent messy HTML.
Cron Expression Builder
Build and explain cron expressions in plain English.
JSONPath Tester
Test JSONPath queries against a JSON document.
Timestamp to Date
Convert Unix timestamps into readable dates.
Date to Timestamp
Convert dates into Unix timestamps.