JavaScript Beautifier

Paste JavaScript and get it back with indentation, spacing and line breaks added. The code is only laid out, never run or changed.

Use the tool

Loading the tool…

About JavaScript Beautifier

Paste JavaScript that is hard to read, such as minified code, and get it back formatted with your choice of indent: 2 spaces, 4 spaces or a tab. You can download the result as a JavaScript file.

Worked example

Paste `function add(a,b){return a+b}`. The output shows the function on several indented lines.

Limits

Formatting does not change what the code does, but it does not check for errors either. Test the result before you use it.

How to use JavaScript Beautifier

  1. Paste your JavaScript.
  2. Choose the indent.
  3. Read the result.
  4. Copy or download it.

Good to know

  • Only spacing and line breaks change. Existing line breaks are kept, because code without semicolons can depend on them.
  • Regular expressions, strings and template strings are copied exactly.
  • The tool does not run your code and does not check it for mistakes.
  • JSX and TypeScript are not supported.

Frequently asked questions

Will it change what my code does?

It is made not to. Only white space is added or changed.

Does it add semicolons?

No. Adding semicolons can change the meaning of some code.

Can it make code smaller?

No, this tool makes code easier to read. Use a minifier for small files.