Skip to content
DeveloperRuns in your browser

JavaScript Minifier

Remove comments and whitespace from JS without renaming identifiers.

Input
No upload needed — instant
Privacy
Nothing is uploaded
Cost
Free · no sign-up · no watermark

Loading tool…

The tool is loading its code on your device. This happens once and is cached for later visits.

Processed entirely on your device

Everything you type or paste is handled by JavaScript running in this tab. No request is sent, nothing is logged and nothing is stored. Close the page and it is gone.

Overview

About the JavaScript Minifier

Minify JavaScript online with a conservative pass that strips comments and insignificant whitespace without renaming identifiers or altering behaviour. In-browser, no upload.

There are two things people call JavaScript minification, and it is worth being clear about which one this is. A full minifier parses your code into an abstract syntax tree, renames every local variable to a single letter, folds constants, drops unreachable branches and re-emits the smallest equivalent program. This tool does the safe half of that job: it removes comments and whitespace that cannot change what the code does, and leaves everything else exactly as you wrote it.

Why conservative is a feature

Renaming identifiers is powerful but fragile. It breaks code that reads function.name, that relies on a variable name matching a string used in reflection or dependency injection, or that shares a global with another separately minified file. A whitespace-only pass has none of those failure modes. The output is still recognisable, still debuggable and still greppable, which is exactly what you want for a snippet you are about to paste somewhere and forget.

What it removes and what it keeps

RemovedKept
Line and block commentsAll identifiers and names
Indentation and blank linesWhitespace inside strings
Spaces around operators and punctuationNewlines inside template literals
Trailing whitespaceWhitespace inside regular expressions

The kept column is the hard part. A regular expression such as one matching a space, or a template literal spanning several lines, contains whitespace that is data rather than formatting. Stripping it would silently change behaviour, so the pass tracks those contexts and leaves them alone.

Automatic semicolon insertion

JavaScript infers semicolons from newlines in a few situations. Joining two lines carelessly can move where a statement ends and change the program. This is the classic reason a find-and-replace on newlines is not a minifier. A correct pass knows where a line break is load-bearing and keeps it, which is why the reduction is smaller than a real compiler achieves but the result is trustworthy.

When to reach for a real bundler

For an application, use Terser, esbuild or SWC in your build. They produce source maps so minified stack traces still point at your original lines, and their renaming and tree-shaking cut far more than whitespace removal can. Use this tool for the small jobs: compressing an inline script, shrinking a bookmarklet, or checking how much of a file is just formatting.

Step by step

How to use the JavaScript Minifier

  1. Paste your JavaScript into the input panel.

  2. Press Minify JavaScript; comments and insignificant whitespace are removed.

  3. Review the output — identifiers and logic are left exactly as written.

  4. Copy the result or download it as a .js file.

Why use it

Benefits and common use cases

What this tool is good for, and what it deliberately does not try to do.

Conservative and predictable

Only comments and whitespace that cannot change behaviour are removed. Variable names, function names and string contents are untouched, so the output is easy to reason about.

No renaming surprises

Because it never mangles identifiers, it cannot break code that relies on function.name, reflection, or names referenced across separately loaded files.

String and regex safe

Whitespace inside string literals, template literals and regular expressions is preserved, which is where a naive whitespace-stripping pass corrupts code.

Runs entirely in your tab

Proprietary or unreleased scripts are never sent to a server — the whole pass happens in the browser.

Questions

Frequently asked questions

Short, honest answers about quality, limits and privacy.

Does this rename variables like UglifyJS or Terser?

No. This is a whitespace and comment minifier, not a full compiler. It never shortens identifiers, rewrites expressions or performs dead-code elimination. That makes it safe and predictable, at the cost of a smaller reduction than a build-time bundler achieves.

Will minifying change how my script behaves?

It should not. Removing comments and insignificant whitespace does not alter semantics. The only place whitespace matters in JavaScript is inside strings, template literals and regular expressions, and those are preserved exactly.

Why does whitespace sometimes matter in JavaScript?

Automatic semicolon insertion means a newline can end a statement, so a minifier must not join two lines in a way that changes where a semicolon is implied. It also matters inside template literals, where newlines are part of the string, and in regular expressions. A conservative pass keeps those intact.

How much smaller does JavaScript get?

A readable, commented script usually shrinks by 20 to 40 percent with whitespace and comment removal alone. Full minifiers that also rename identifiers and drop dead code can reach 50 to 70 percent, which is why production builds use a real bundler.

Should I use this in production?

For a quick inline snippet or a small standalone script, yes. For an application bundle, use a build-time minifier such as Terser or esbuild that also tree-shakes, mangles names and produces source maps. This tool is best for one-off compression and for seeing exactly what whitespace removal does.