JavaScript Minifier
Runs entirely in your browser
Safely shrink JavaScript by removing comments and indentation. This only rewrites text — it never executes your code.
What is JavaScript Minifier?
JavaScript Minifier removes comments and indentation to shrink your code, while keeping original line breaks so behavior can never silently change due to automatic semicolon insertion. It's a safe, conservative minifier rather than a full AST-based one.
How to use JavaScript Minifier
- Paste your JavaScript into the Input box.
- Click Minify.
- Copy the compressed result from the Output box.
Features
- Strips // and /* */ comments.
- Removes indentation and unnecessary spacing.
- Preserves original line breaks to avoid ASI-related behavior changes.
- Correctly recognizes strings, template literals and regex literals.
- Never uses eval — your code is never executed.
- 100% client-side — your code never leaves your browser.
Frequently Asked Questions
Does this execute my code?
No. This tool never uses eval or runs your code — it only rewrites the text.
Why does the output keep line breaks instead of becoming one line?
Removing a line break can silently change what JavaScript does, because of automatic semicolon insertion (ASI) — doing this safely requires a full parser, not just a tokenizer. This tool keeps original line breaks and instead strips comments and indentation, which is where most of the size savings come from anyway.
Is my code uploaded to a server?
No. Minifying happens entirely in your browser.
For maximum compression, what should I use instead?
A build-time tool like Terser or esbuild, which parses a full AST and can safely rewrite statement boundaries, rename variables and remove line breaks.