Developer tool / 17
JavaScript Minifier
Conservatively remove comments, indentation, and blank lines without renaming identifiers.
JavaScript Minifier: TOEA scans strings, template literals, and regular-expression literals, removes line and block comments outside them, trims indentation outside template literals, and preserves line boundaries for safer automatic-semicolon behavior. Runs 100% locally in your browser with zero server file uploads.
- Category
- Developer tools
- Runs
- In your browser
- Cost
- Free · no sign-up
- Availability
- Ready to use
Runs entirely in your browser
What is copied unchanged
Strings, template literals, and regular-expression literals are copied exactly, so the // in /https?:\/\// is not taken for a comment and indentation inside a multi-line template literal stays part of the string. A / starts a regex when it follows an operator, an opening bracket, a comma, a semicolon, a brace, or a keyword such as return or typeof, and means division after a name, a number, or a closing bracket. That is the usual rule, and it misreads only rare code such as if (ok) /x/.test(s).
Line breaks are kept and blank lines dropped, because automatic semicolon insertion depends on them: joining let a = b and (c || d).run() onto one line would call b as a function. A block comment that spans lines leaves one line break behind for the same reason.
When to use a build tool
This page removes comments and indentation only. Build-time minifiers such as Terser and esbuild also shorten local variable names, drop unreachable code, and write a source map, and typically produce a much smaller file. Use them for application bundles; use this for a snippet, an embed code, or a script you paste into a page. Comparing input and output in the diff checker shows exactly which lines changed.
How to use it
- Paste JavaScript.
- Choose Minify JavaScript.
- Test, copy, or download the output.
Privacy & limitations
Source stays local. This deliberately conservative minifier is not obfuscation; test generated code before release.
Related tools
Frequently asked questions
Why are names not shortened?
Identifier mangling is intentionally omitted to reduce surprises across snippets and integrations.
Why are some line breaks retained?
Keeping line boundaries avoids changing JavaScript automatic-semicolon behavior.
Free tool · runs in your browser · no account required