Compress · Shrink · Copy
Minify JavaScript Online
Updated: June 2026
Comments and indentation make JavaScript readable, but they ship as dead weight. Minifying removes them to produce a smaller script that downloads and parses faster — done carefully so the code still runs exactly as written.
Free · No upload · Instant in the browser
A careful, safe minifier
JavaScript minification is trickier than CSS or HTML because the language uses automatic semicolon insertion: in some code a line break stands in for a semicolon, and removing it silently changes behaviour. This minifier is conservative by design. It tokenises the code, strips comments, and removes indentation and redundant spaces — but it preserves the line breaks that existed in the source, so any statement that relied on a newline to terminate keeps working.
It also keeps the minimum spacing needed to stop tokens merging, so two identifiers never collide and operators like + + are not turned into ++. The output is smaller and still correct.
What it removes
- Line comments (
//) and block comments (/* … */). - Leading indentation and trailing whitespace on every line.
- Redundant spaces around operators and punctuation.
- Blank lines collapsed away.
What it keeps is just as important: the line breaks and the one-space separators that the code needs to keep its meaning.
Why minify JavaScript
Scripts are often the heaviest assets on a page, and every kilobyte delays interactivity. Minifying shrinks them so they download faster and the browser has less to parse before the page becomes usable. Combined with gzip or Brotli on the server, minified JavaScript is meaningfully smaller than its readable source. The pattern is the same as for CSS and HTML: keep the readable version in your repository, serve the minified version to users.
How to minify, and how to reverse it
Paste your script into the tool and switch to the Minify tab. The compressed code appears with the percentage saved. Copy it or download it as a .min.js file. If you later need to read a minified file — yours or someone else’s — switch back to Beautify and the same tool expands it into fully indented code.
Nothing leaves your machine
Minifying runs locally in your browser. Your code — including any endpoints, keys or unreleased logic it contains — is never uploaded. Check by minifying with the network tab open, or work offline and watch the tool keep running. With no server round-trip, even a large file compresses instantly.
Frequently asked questions
Is minifying JavaScript safe?
This minifier is conservative: it strips comments and indentation but preserves the line breaks that matter for automatic semicolon insertion, so the minified code keeps running.
How do I minify JS?
Paste your JavaScript into the tool and switch to the Minify tab. Comments and whitespace are removed and the compact code appears, ready to copy or download.
Can I reverse a minified file?
Yes. Switch to Beautify and the tool expands minified JavaScript back into readable, indented code.
Is my code uploaded anywhere?
No. Minifying runs locally in your browser. Nothing is sent to a server and the tool works offline once loaded.