JavaScript Minifier

Shrink JavaScript by stripping comments and collapsing whitespace safely.

  • No sign-up
  • Files stay local. Nothing is sent to our servers.
  • Nothing uploaded
  • Free forever

Drop text files here

.js, .txt, .csv, .tsv, .xlsx, .xls, .html, .xml, .json, .log · local only · up to 1000 MB total · Excel up to 256 MB

The JavaScript Minifier reduces the size of your code by removing comments and collapsing the extra whitespace, while carefully leaving the contents of strings, template literals and regular expressions untouched. The result is a leaner script that keeps the same behaviour but drops the indentation, blank lines and notes that inflate a source file.

It is aimed at developers who want a quick, dependency-free way to shrink a small script, a snippet or a utility file before embedding or shipping it. When you do not need a full build pipeline, pasting code here gives you an immediate compact version without installing anything or configuring a bundler.

Everything runs locally in your browser using JavaScript, so the code you paste is never uploaded, logged or stored. That keeps proprietary logic and unreleased scripts entirely on your own device while you minify them.

Features of JavaScript Minifier

  • Removes both single-line and multi-line comments throughout the code.
  • Collapses runs of whitespace so indentation and blank lines no longer inflate the file.
  • Protects the contents of single-quoted, double-quoted and template string literals.
  • Detects regular expression literals and copies them verbatim so their spacing is preserved.
  • Keeps a newline where the source had one so automatic semicolon insertion is respected.
  • Reports the original and minified character counts plus the percentage of size you saved.
  • Copies the minified script or downloads it as a file ready to embed or ship.

How to use JavaScript Minifier

  1. Paste your JavaScript code into the input box.
  2. The tool instantly strips comments and collapses the whitespace outside of strings and regex.
  3. Check the statistics to see how many characters and what percentage you saved.
  4. Review the output to confirm it still reads and behaves the way you expect.
  5. Copy the minified script or download it as a file to embed in a page or ship with your project.

Benefits of JavaScript Minifier

  • Smaller scripts download faster, improving page load and perceived performance.
  • Stripping comments removes internal notes before code ships to a public page.
  • A quick, dependency-free minify avoids setting up a full build tool for a small file.
  • Compact JavaScript is easy to inline in a page or embed as a string.
  • The size statistics quantify exactly how much smaller the script became.
  • Because minification is local, proprietary logic never leaves your own device.

Honest limitation up front: this is a safe, lightweight minifier, not a full compiler like Terser. It removes comments and whitespace and protects strings and regular expressions, but it does not rename variables, remove dead code or perform the aggressive transformations that a true optimiser applies. For production builds of large applications you should still use a dedicated bundler and minifier; this tool is best for quick jobs on small scripts and snippets.

Because collapsing all newlines could change the meaning of code that relies on automatic semicolon insertion, the minifier deliberately preserves a newline wherever the source had one, while stripping the surrounding indentation and blank lines. This conservative choice trades a little extra size for safety, keeping constructs like a bare return followed by a value on the next line behaving exactly as written.

The minifier walks through your code character by character, tracking when it is inside a string, a template literal, a comment or a regular expression, so it never mistakes code punctuation inside a string for something to collapse. Regular expression detection relies on common preceding-token heuristics rather than a full parser, so in rare ambiguous cases such as a regex following certain keywords it may not be detected; review the output before shipping anything critical.

Questions about JavaScript Minifier

Is this a full minifier like Terser?
No. It is a safe, lightweight minifier that removes comments and collapses whitespace while protecting strings and regex. It does not rename variables or remove dead code. For large production builds, use a dedicated bundler and minifier.
Will it break my strings or regular expressions?
No. The tool tracks when it is inside a string, template literal or regular expression and copies those contents verbatim, so the whitespace and characters inside them are never altered during minification.
Does it handle automatic semicolon insertion?
It preserves a newline wherever the source had one, so code that relies on automatic semicolon insertion keeps working. This trades a little size for safety compared with collapsing every newline into a space.
How much smaller will my code get?
It depends on how many comments and how much indentation the source has. The tool reports the original and minified character counts and the percentage saved so you can see the exact reduction for your file.
Is my code uploaded to a server?
No. Minification runs entirely in your browser with JavaScript, so nothing you paste is transmitted, stored or logged. Proprietary logic stays safely on your own device.
How your data is handled: This tool runs entirely in your browser. Nothing is uploaded or stored on our servers.

More minification tools to try