✨

JS Beautifier

Turn minified JavaScript into readable, indented code, or strip it back down. Token-aware, so strings and regexes are never corrupted. Runs in your browser.

✓ Free forever✓ No signup✓ 100% private — runs in your browser
JavaScript Beautifier & Minifier
Format minified JavaScript into readable, indented code — or strip it back down. Useful for reading a bundled script you did not write.
JavaScript Input
Indent
Output
Formatted JavaScript appears here…

Minified JavaScript is one long line with every optional byte removed. That is correct for shipping and impossible to read. Formatting it is the first step to understanding a bundle you did not write — a third-party widget, a script you inherited, or your own build output when something is wrong with it.

How to use the JS Beautifier

  1. Paste your JavaScript, or load a .js file
  2. Choose an indent width — 2 spaces, 4 spaces or tabs
  3. Click Beautify to format it, or Minify to strip it back down
  4. Copy the result or download it

Why a naive formatter corrupts code

The obvious approach — add a newline after every ; and { — breaks on the first string that contains one. This is valid JavaScript:

const t = "function x(){return 1}";

A regex-based formatter reformats the inside of that string, changing the data. The same applies to template literals, comments and regular expressions. A regex containing a quote — s.replace(/"/g, '"') — breaks naive scanners particularly badly, because the lone double quote looks like the start of a string.

This formatter tokenises first: it walks the source identifying strings, template literals, comments and regex literals, and only touches whitespace between tokens. Everything inside a literal is passed through byte for byte.

What formatting can and cannot recover

Indentation and line breaks come back. Structure becomes visible again — you can see which braces pair up, where functions begin and end, and how deeply things nest.

What is gone for good is anything the minifier removed rather than compressed. Comments are deleted, not hidden. More significantly, most minifiers rename local variables to single letters, and that mapping is not stored anywhere. A formatted bundle is readable but anonymous — function a(b,c){...} tells you the shape, not the intent.

If the build published a source map (a //# sourceMappingURL comment at the end of the file), that is a far better route: it restores original names, files and line numbers. Formatting is the fallback when no map exists.

Frequently asked questions

Is my code sent to a server?

No. Formatting happens entirely in your browser, which matters because the code you need to inspect often contains API endpoints, keys or unreleased logic.

Will formatting change what my code does?

No. Only whitespace between tokens changes. The contents of strings, template literals and regular expressions are preserved exactly.

Can it recover my original variable names?

No. Minifiers rename local variables to single letters and that mapping is not kept in the output. Use a source map if the build published one — that restores names, files and line numbers.

Why are the comments gone from my minified file?

Minification removes them from the file entirely. They are not hidden or compressed — there is nothing to restore.

Does this handle modern JavaScript?

Yes — arrow functions, classes, template literals, optional chaining, nullish coalescing and spread syntax are all tokenised correctly.