JavaScript Minifier

Minify JavaScript comments and spacing locally. Preserve strings, regexes, template literals and important line breaks; validate plain JavaScript before copying.

This tool works entirely in your browser. You can load the sample, process the text, copy the result, and clear the page whenever you want to start again.

The output section updates after you run the tool. Use the summary cards and result panel below for extra detail when available.

Processing your text...
Ready.

Result details will appear here after you run the tool.

Compact JavaScript comments and repeated spacing in your browser. The tool parses source code before changing it, preserving strings, regular expressions, template literals and line boundaries needed for automatic semicolon insertion.

How to minify JavaScript

  1. Paste a complete JavaScript script or module, or choose Load Sample.
  2. Select Minify Code. Invalid or unsupported syntax produces an error instead of a damaged result.
  3. Compare the Original, Minified and Saved character counts, then copy the output.
  4. Run your application's tests with the result before publishing it.

Example

Input const label = "a // b"; // explanatory comment produces const label = "a // b";. The comment disappears while the quoted slashes remain part of the string.

What is preserved

Every JavaScript token keeps its original text. Newlines between tokens are retained as one newline where needed to preserve automatic semicolon insertion. License comments marked with !, @license or @preserve, and an initial hashbang, are retained.

Limits and troubleshooting

This is conservative whitespace and comment compaction. It does not rename variables, fold expressions, remove unused code, bundle modules or generate source maps. Already compact input may not become smaller. TypeScript, JSX and incomplete code fragments are not supported; compile them to plain JavaScript first. The local Acorn parser is loaded only on this page. If it cannot load, reload the page before trying again.

Privacy

The parser reads source code locally. The tool never executes the supplied JavaScript and does not upload it.

Frequently asked questions

Will quoted comment characters be removed?

No. Strings, regular expressions and template literals are identified by the parser and kept unchanged. Only actual comments are considered for removal.

Why are some line breaks kept?

JavaScript uses line breaks for automatic semicolon insertion and certain syntax rules. The tool retains those boundaries to preserve behavior.

Does this support TypeScript or JSX?

No. Paste a complete plain JavaScript script or module. Compile TypeScript or JSX before using this tool.

Use the JavaScript Minifier Now

Paste your text above, adjust the settings if needed, and generate a clean browser-side result in seconds.

Back to Tool