JavaScript Minifier

Free JavaScript minifier. Compress JS by stripping comments and whitespace while preserving the spaces that keywords need, with a reported size saving.

AI-ready Use this tool with AI

This tool has a free JSON API. Copy a prompt or skill below to use it with ChatGPT, Claude, or any AI agent — no API key needed.

API docs
Paste your JavaScript above.

How javascript minifier works

JavaScript minification shrinks a script by removing comments, redundant whitespace, and the spaces around operators and punctuation that the parser does not need. The minified code is functionally identical but smaller, so it downloads and parses faster.

This minifier removes single-line (//) and multi-line (/* */) comments, collapses whitespace, and strips spaces around operators and punctuation. It carefully preserves a space after keywords like return, typeof, and new where removing it would change the meaning (return x must stay "return x", not "returnx"). It reports the size saving in bytes and as a percentage.

Paste your JavaScript and click Minify. The tool is a fast transform suitable for small to medium scripts. It does not rename variables or apply advanced optimisations — for large production bundles use a full bundler like esbuild, terser, or Rollup, which can also handle modules and tree-shaking.

Frequently asked questions

What does minification remove?
Comments (// and /* */), redundant whitespace, and spaces around operators and punctuation. Spaces after keywords like return are preserved so the code keeps its meaning.
Will minification break my code?
The transform preserves keywords, identifiers, and values. The space after keywords like return and typeof is kept so "return x" does not become "returnx". For safety, always test minified production code.
Does it rename variables?
No. This minifier only removes whitespace and comments. Variable renaming and dead-code elimination need a full parser-based tool like terser or esbuild, which can shrink code further but require a build step.
How much size can I save?
Typically 30 to 60 percent for hand-written code with comments and indentation. The exact saving depends on how verbose the original is and is reported by the tool.