To unminify JavaScript means taking a compressed, single-line file and re-adding the whitespace, line breaks, and indentation that make it readable. Minifiers strip all of that out to shrink download size, which is great for production and terrible for reading. Here is how to beautify JavaScript back into something you can actually follow.
What unminifying does (and does not) recover
Beautifying restores structure, not the original source. It is important to know the difference before you trust what you see.
- Recovered: line breaks, indentation, consistent spacing around operators and braces, and proper statement separation. The logic becomes scannable again.
- Not recovered: original variable and function names. Minifiers rename
userAccounttoaandcalculateTotaltobto save bytes, and that mapping is gone unless a source map exists. - Not recovered: comments. Minification deletes them, so beautifying cannot bring them back.
In short, you get readable code with cryptic names, not the developer’s original file. That is still enough to trace control flow, spot a function, or understand what a script is doing.
When you would unminify JavaScript
There are plenty of legitimate reasons to reach for this:
- Debugging your own build output: a bundler produced a one-liner and the error points into it. Beautifying makes the stack trace location readable.
- Reading a library: you want to understand how a dependency actually behaves, not just what its docs claim.
- Auditing a third-party script: before you trust a snippet on your site, you can format it and read what it really does.
How to unminify JavaScript in your browser
- Open the JS Unminifier.
- Paste your minified code into the input, or drop in the contents of a
.min.jsfile. - The tool reformats it instantly with proper indentation and line breaks.
- Read through the result, then copy the beautified output for your editor.
Everything runs in your browser. Your code is never uploaded to a server, which matters when you are inspecting proprietary or sensitive scripts. If you only need to format a chunk you copied from devtools, the JS Unminifier handles partial snippets just as well as full files.
A quick note on accuracy
Beautifying is safe: it changes formatting, not behavior. The reformatted code runs identically to the minified version. What it will not do is reverse the variable mangling or reconstruct comments, so do not expect a pristine source file. If you have the matching source map, your browser devtools can do a fuller reconstruction. For everything else, formatting is the practical win.
Related tools
- JS Minifier - go the other way and shrink your code for production.
- CSS Minifier - compress stylesheets to cut page weight.
- HTML Minifier - strip whitespace from markup before you ship.
Paste the one-liner, let it breathe, and read your code like a human again.