Javascript beautifier
What is a Javascript Beautifier?
Minified JavaScript from a production bundle, a third-party widget or an old project is almost impossible to read: everything on one line, no indentation, short variable names. The JavaScript beautifier reformats the code with proper indentation and line breaks so you can understand, debug or review it.
How to use it
- Paste the JavaScript code.
- Choose indentation options if available.
- Copy the formatted result.
Example
Input:
function f(a,b){if(a>b){return a-b}else{return b-a}}const r=[1,2,3].map(x=>x*2);Output:
function f(a, b) {
if (a > b) {
return a - b
} else {
return b - a
}
}
const r = [1, 2, 3].map(x => x * 2);What beautifying can and cannot do
- It restores layout, not original names. Minifiers rename variables to single letters; a beautifier cannot know the original names.
- It does not change behaviour. Only whitespace and line breaks are modified.
- It is not deobfuscation. Deliberately obfuscated code, with encoded strings and control-flow tricks, stays hard to read.
Better options when you have them
- If the site ships source maps, browser developer tools show the original source files with real names.
- Chrome and Firefox developer tools have a built-in pretty-print button, shown as
{ }, in the Sources panel. - For your own projects, use Prettier in your editor and CI so all code is formatted consistently.
Security tip
Beautifying suspicious scripts, for example a skimmer injected into a checkout page, is a common first step in analysing them. Never run code you do not trust; reading it formatted is safe.
Formatting happens entirely in your browser.
Frequently Asked Questions
Can a beautifier recover original variable names?
No. Minifiers replace names permanently. Only source maps can map minified code back to the original names.
Does beautifying change how the code runs?
No. Only whitespace and line breaks change.
What is the difference between beautifying and deobfuscating?
Beautifying only fixes layout. Deobfuscation tries to undo deliberate tricks such as encoded strings and is much harder.
Is my code uploaded?
No. The code is formatted locally in your browser.