JS Minifier / Beautifier
Minify or pretty-print JavaScript in your browser.
How to use
- 1 Paste your JavaScript into the input box.
- 2 Choose Minify to shrink it or Beautify to format it.
- 3 For Beautify, pick a 2- or 4-space indent.
- 4 Review the output and the size saved when minifying.
- 5 Copy the result.
About JS Minifier / Beautifier
The JS Minifier / Beautifier compresses JavaScript down to the smallest equivalent text, or expands cramped one-liners back into clean, indented code you can actually read.
Minifying strips comments and collapses every run of insignificant whitespace, keeping only the single spaces that JavaScript genuinely needs between keywords and identifiers.
The tool tokenises your source first, so string literals, template literals and regular-expression literals are copied through untouched — a slash inside a regex character class or a double slash inside a string will never be mistaken for a comment, and the whitespace inside a template literal is preserved exactly.
Beautifying does the reverse: it re-indents braces and brackets, puts statements on their own lines and applies a consistent two- or four-space indent so a minified bundle becomes legible again.
The two directions round-trip cleanly, which makes the tool handy for inspecting third-party snippets, tidying code pasted from chat, or quickly estimating how much a file shrinks.
This is a deliberately lightweight lexical pass rather than a full compiler, so it does not rename variables, fold constants or remove dead code — the output is always a faithful, equivalent rewrite.
Everything happens locally in your browser; your code is never uploaded, logged or stored, and the tool keeps working offline once the page has loaded.
FAQ
Will minifying break my regular expressions or template strings?
No. The tool tokenises the source so strings, template literals and regex literals are preserved exactly. Only whitespace and comments outside those tokens are removed.
Does it rename variables or remove dead code like a real bundler?
No. This is a fast lexical minifier, not a compiler. It strips comments and whitespace to produce a smaller but equivalent file, leaving identifiers and logic intact.
Is my code uploaded anywhere?
No. All processing happens in your browser. Nothing you paste is sent to a server, logged or stored.