About this tool
Format, beautify, and clean minified or messy JavaScript code with options to adjust tab indentation size and copy output.
JS Beautifier re-indents minified or run-together JavaScript by tracking brace depth: it breaks the code onto one statement per semicolon, opens a new line after every `{`, and indents each level by 2, 4 or 8 spaces. An operator-padding switch adds single spaces around assignment, comparison and arithmetic operators, so `a=b+1` becomes `a = b + 1`. It is a fast textual re-formatter for making a minified bundle or a pasted snippet readable — not a parser-based printer like Prettier, so treat the output as a reading aid rather than a replacement for your source file.
Open JS Beautifier on AltFTool — it loads instantly in your browser.
Paste minified or run-together code into the Input JS Code box, or press Load Sample JS to try it.
Set Indentation Size to 2, 4 or 8 Spaces, toggle "Add spaces around operators", then press Beautify JS Code.
Read the Beautified JS Code panel, then use Copy Code or Download (.js), which saves script.beautified.js.
Nesting level is tracked as lines open and close braces, so blocks line up instead of being wrapped at an arbitrary column.
Switch between 2, 4 and 8 spaces to match the project you are pasting into rather than a fixed house style.
Turn padding on to open up dense minified expressions, or off when you want the original spacing left alone.
No. Prettier parses JavaScript into an AST and prints it back, so it is safe on any valid program. This tool works on the text with regular expressions, tracking `{` and `}` to decide indentation, which makes it instant and dependency-free but means it does not understand syntax.
It can, in specific cases. Because the rewriting is textual, braces, semicolons or operators that appear inside string literals, template literals, regular expressions or comments may be treated as code and reformatted. Use it to read unfamiliar or minified JavaScript, and re-run your own formatter before committing anything.
Only the whitespace part. Layout, indentation and statement breaks come back, but names do not: a minifier that renamed `userAccount` to `n` has thrown that information away, and no beautifier can recover it without a source map.
Three: 2, 4 and 8 spaces, applied per nesting level. Two spaces is the common default in modern JavaScript style guides, four suits code being read alongside other languages, and eight makes deep nesting visually obvious when you are auditing a bundle.