Turn minified or messy JavaScript into readable, indented code.
Loading the tool...
How to use JS Beautifier
Paste your JavaScript.
Choose an indent and brace style.
Copy the beautified code.
About JS Beautifier
Minified JavaScript is meant for machines. When you have to debug a production bundle or read a third-party snippet, the first thing you need is whitespace. This beautifier restores line breaks and indentation so you can follow the control flow again.
It cannot restore the names of variables that a minifier shortened to single letters, so a function called a stays a. What you get back is structure, and for most debugging that is enough to start.
Frequently asked questions
Does beautifying change what the code does?
No. Only whitespace and line breaks change. The beautifier does not rename anything or reorder statements.
Can it restore the original variable names?
No. Names removed by a minifier are gone. If the bundle came with a source map, your browser's developer tools can use it to show the original names.
Does it support modern syntax?
Yes, arrow functions, classes, template literals, async and await, optional chaining and ES modules are handled.
What is the difference between this and the Babel formatter?
This tool is a lenient beautifier that re-indents code and never fails on syntax it does not understand. The Babel formatter parses the code and prints it from scratch, which is stricter and gives more consistent results.