JavaScript beautifier
Beautify JavaScript in your browser: nothing is uploaded, there is no limit on the size, and minified or badly formatted code becomes readable, indented code. Only the whitespace changes.
How it works
-
Paste your code
Paste the code in the left box or open a file. No code to hand? Click Example.
-
Instant result
The result appears as you type. If there is an error, you see the line and character.
-
Copy or download
Copy the result with one click or save it as a file for your editor or project.
Options
- Indent: 2 spaces, 4 spaces or a tab.
- Braces: on the same line (
if (a) {, the usual JavaScript style) or on a new line.
This is formatting, not deobfuscation: variable names that were shortened to a and b stay short. It uses js-beautify, running in your browser. Formatting CSS instead? Use the CSS beautifier.
Reading code you want to understand
Paste a minified library, a bookmarklet or an inline script from a web page, and you see one statement per line with proper indentation. It makes it easy to follow the control flow and to find the function you are looking for. Be careful with code you do not trust: reading it is safe, but do not run it in your console or add it to a site unless you understand what it does.
Limits of formatting
A beautifier cannot restore what a minifier removed. Variable names that were shortened to a, b and c stay that way, comments that were stripped are gone, and bundled code from several files is still one file. If the minified file has a source map (a .map file), your browser's developer tools can show the original names, which is better for real debugging.
Style choices
Braces on the same line is the common JavaScript style; a new line is the Allman style used in some teams. Indent size is a matter of taste: 2 spaces is common in JavaScript projects. For a team, a formatter such as Prettier in your editor keeps the style consistent automatically.
For markup and styles, see the HTML formatter and CSS beautifier. Working with data instead of code? The JSON formatter validates as it formats.
Frequently asked questions
Does beautifying change what the code does?
No. Only whitespace is changed. Strings, template literals and regular expressions are left alone.
Can it make minified code readable again?
It restores the layout, but not the original variable names or comments. A source map is the way to get those back.
Does it support modern syntax such as async/await and classes?
Yes. The formatter handles current JavaScript, including template literals and arrow functions.
Is my code uploaded?
No. It is formatted in your browser and never leaves your device.