Developer Tools

JavaScript Minifier

Safely minify JavaScript: strip comments and collapse whitespace while preserving line breaks to protect automatic semicolon insertion.

Tool

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

  1. Paste your JavaScript into the input.
  2. Leave Remove comments on to strip both line and block comments.
  3. 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.

Frequently asked questions

Yes. The tool only removes comments and insignificant whitespace, and keeps line breaks so automatic semicolon insertion still behaves correctly.
No. It does not perform name mangling, so the output stays readable and predictable.
Because some statements rely on line breaks for automatic semicolon insertion; removing them could change behaviour.

Related tools

Guides for this tool