JavaScript Beautifier

Reformat minified or messy JavaScript with 2 spaces, 4 spaces or tabs, view the result, copy it or use it as new input. Runs in your browser.

Input
Result

About JavaScript Beautifier

The JavaScript Beautifier re-indents minified or untidy JavaScript so it is easy to read. Paste the code, pick the indent, and copy the result or use it as new input.

Indent

2 spaces are common in front-end projects, 4 spaces in many back-end code bases, and tabs let your editor decide.

Bracket warning

If brackets do not balance, the tool tells you how many are left open.

Whitespace only

The beautifier changes spacing, not your code, and it does not check that the code runs.

Good for

Inspecting a minified library, reading example code, and looking at snippets from customers.

Private

Everything runs in your browser. Nothing you paste is uploaded.

How to use JavaScript Beautifier

  1. Paste the JavaScript into the Input box, or press Open file or Load example.
  2. Choose the indent: 2 spaces, 4 spaces or Tab.
  3. Read the formatted code in the Result box.
  4. Copy it, download it as a .js file, or press Use result as input to format it again.

Related guide: Speed Up Your Website: Minify CSS, JavaScript and HTML

Help & FAQ

What does a JavaScript beautifier do?

It changes the whitespace of code so that each statement and block has its own line and indent. It does not change what the code does.

Can it un-minify variable names?

No. Short names such as a, b and c stay as they are. Only the layout becomes readable.

Which indent options are there?

2 spaces, 4 spaces or a tab.

Does it fix errors in our code?

No. It may show a hint about unbalanced brackets, but it is not a full syntax checker or linter.

What happens with template literals and comments?

In the test, a template literal with ${} stayed untouched and a // comment stayed in place after the code.

Does it add or remove semicolons?

No. It keeps the code as written and only changes spacing and line breaks.

Can we format a whole file?

Yes. Press Open file to load a .js file, or paste the content.

What does Use result as input do?

It moves the formatted result into the Input box so that you can format it again with another indent.

Is our code uploaded?

No. The code is processed in your browser. In a test, only small analytics calls were made.

Is the result safe to run?

The beautifier does not run your code, but formatted code does the same as the original. Only run code you trust.

Can it format JSX, TypeScript or JSON?

It is meant for JavaScript. Other syntaxes may not format correctly. For JSON, use the JSON Formatter.

How do we make the code small again?

Use the JavaScript Minifier, which removes whitespace and comments for production.

More in Developer Tools

See all 39 in Developer Tools