November 9, 2026

JavaScript Minifier

JavaScript files carry the same invisible weight as stylesheets: comments for humans, indentation for readability, blank lines for structure — all of it downloaded by every visitor on every page. This minifier strips that formatting weight while leaving your code’s behaviour untouched. It removes comments and collapses whitespace using a careful tokeniser that respects strings, template literals and regular expressions, so code containing ‘http://’ inside a string or a regex that looks like a comment survives intact. Paste a script, see the minified output and the size saving, and ship the lean version — keeping your readable source for editing, as minification is a one-way convenience, not a place to work.

Quick Answer: Paste JavaScript to strip comments and whitespace and get a compact, behaviour-identical script with the size saving shown.

Free Online Tool

JavaScript Minifier

Leaner scripts, same behaviour.


0 BOriginal
0 BMinified
0%Saved



How to Use the JavaScript Minifier

  1. Paste your JavaScript into the input box.
  2. Press Minify JavaScript.
  3. Check the original versus minified sizes and the percentage saved.
  4. Copy the minified output into your production file.
  5. Load-test the page with the minified script before you consider the job done.

Key Features

  • Removes line and block comments plus collapsible whitespace.
  • String-, template- and regex-aware, so code content is never eaten as a ‘comment’.
  • Size report with bytes saved and percentage.
  • No renaming or restructuring — output maps 1:1 to your source logic.
  • Everything runs in your browser; proprietary code stays on your machine.

Best Practices and Tips

  • Keep the unminified source as your working file forever; minified code is a build artefact.
  • Test after minifying: run the page’s key interactions once, because a rare edge case in source formatting is exactly what testing exists for.
  • Real-world gains stack with Brotli or gzip — minified code also compresses slightly better.
  • For multiple files, bundling plus minifying saves more than minifying alone, thanks to fewer requests.
  • If a script uses automatic semicolon insertion aggressively, eyeball the output around return statements — this minifier keeps line breaks where ASI could bite, but paranoia is cheap.

Common Mistakes to Avoid

  • Minifying code that relies on comment-based directives (some licence or build comments must be preserved) without checking.
  • Treating minification as obfuscation for security — it is neither; anyone can still read minified logic with effort.
  • Editing the minified file directly and losing the change at the next build.
  • Expecting minification to fix slow code: it shrinks download size, not execution cost.

Frequently Asked Questions

Is this the same as what build tools like Terser do?

It performs the whitespace-and-comments half of the job — the part that is always safe. Advanced minifiers also rename variables and restructure code for extra savings, which requires full parsing. For hand-managed sites and quick jobs, the safe half captured here delivers most of the benefit with none of the risk.

Will it break code with regexes or URLs in strings?

That is exactly what the tokeniser protects. It tracks whether the scanner is inside a string, template literal, comment or regex, so ‘//’ inside ‘https://example.com’ is treated as content, not the start of a comment.

How much size can I save?

Unminified hand-written scripts typically shrink 25 to 45 percent. Comment-heavy teaching-style code saves the most; already-compact code saves the least. Your exact figures are shown after each run.

What about source maps?

This tool does not generate them. If you need to debug minified code in production with original line numbers, use a full build pipeline; for straightforward sites, testing the minified output directly is the pragmatic route.

Is my code uploaded anywhere?

No. The minifier is JavaScript running in your tab on your machine — a neat recursion, and the reason it is safe for proprietary and pre-release code.

Related Tools