About the JavaScript Minifier
The JavaScript Minifier runs entirely in your browser — your data never leaves your machine. Paste, click and copy the result.
This minifier removes comments and collapses indentation and repeated spaces to shrink JavaScript — but it deliberately keeps line breaks, because newlines are significant in JavaScript thanks to automatic semicolon insertion (ASI). That makes it a safe, predictable choice when you do not want aggressive identifier renaming.
How to use this tool
- Paste your JavaScript into the input.
- Leave Remove comments on to strip both line and block comments.
- Click Minify JavaScript and copy the smaller output.
Why line breaks are kept
In JavaScript, a missing semicolon can be inferred from a newline. Aggressively removing every newline can merge two statements and change behaviour. This tool keeps line breaks and only squeezes indentation and duplicate spaces, so the semantics stay the same.
Developer tip
For maximum compression, use this tool for a quick pass and a build-time tool such as esbuild or Terser when you also want identifier renaming and dead-code elimination.
Who is this tool for?
Developers reducing script size without a full build pipeline, and anyone tidying up a snippet before adding it to a page.