Format and beautify JavaScript

Re-indent minified or messy JavaScript. Pick indent and brace style. The code is never run.

How it works

  1. Paste your JavaScript
  2. Choose indent and brace style
  3. Copy the formatted code

What the formatter changes

The page changes layout only. It puts each statement on its own line, indents blocks one level per brace, and puts spaces around operators and after commas, so a minified line such as if(!a){return 1} becomes three readable lines. Choose 2 spaces, 4 spaces or a tab for the indent. Your names, strings, numbers, comments and the order of the code are left alone. Semicolons are not added or removed: a line that had none still has none. Blank lines between statements are kept, up to 2 in a row.

Brace style and arrays

Same line keeps the opening brace at the end of the line, as in function f() { and puts else on the line of the closing brace. Own line moves every opening brace to a line of its own. Else on new line keeps opening braces at the end of the line but starts else, catch and finally on a new line. Keep array indentation is off by default, so a list is re-laid out by the formatter. Turn it on to keep the indentation of lists that you already wrapped over several lines, which suits hand-aligned data tables.

What it never does

The code is not run. It is read as text, so a call such as deleteEverything() in your input does nothing, and nothing is loaded from any address in it. It is not minified, renamed or obfuscated either. If you paste working code you get working code back, because only white space is touched. The page does not check the code for errors. Code with a syntax error is still laid out as far as the formatter can follow it, and the result may look odd after the mistake.

Limits and where it runs

The work happens in this tab. The code is not sent to a server, not saved and not put in the page address. Only your choices are remembered in this browser. The formatting code is a separate download that loads when the page opens. Up to 500,000 characters are handled. Above 100,000 characters the result follows your typing after a short pause, and a very large bundle can take a few seconds to lay out. Longer text shows a message asking you to split it.

Frequently asked questions

Is my code executed?

No. The text is only read and laid out as characters. Nothing in it is evaluated, imported or sent anywhere, so it is safe to paste code you do not trust.

Can it minify or obfuscate?

No. This page only adds line breaks and indents. It never shortens names or removes code.

Will it add missing semicolons?

No. The formatter leaves semicolons as you wrote them. A line without one stays without one, which is valid in many cases and not in others, so check the result if your code depends on automatic semicolon insertion.

Why does broken code still produce output?

The formatter does not parse the code strictly. It works from the text and keeps going past an unclosed bracket or a stray symbol, so the output near the mistake may be odd. Use a linter when you need errors.

What is the size limit?

500,000 characters per paste, roughly a 500 KB script. A minified library near that size takes a few seconds to format.