JS Minifier

Minify your JavaScript code by stripping comments and unnecessary whitespace safely, without changing the semantics. Runs in your browser, GDPR-compliant.

How useful is this tool?

The result will appear here …

How to use this tool (video)

This video is hosted on YouTube. When you play it, data may be sent to Google.

JS Minifier: shrink code safely

The JS Minifier removes comments and unnecessary whitespace from your JavaScript to shrink the file before shipping. Smaller code means faster load times and less bandwidth for your visitors. Minification is intentionally conservative: newlines are preserved so automatic semicolon insertion cannot break your logic.

Strings, template literals and RegExp literals are never modified. The result is behaviorally identical to the original, even for tricky constructs like division by a RegExp or nested template strings. Paste your code and click Minify to get the minified output plus the savings in characters and percent.

How it works

The minifier analyzes JavaScript code and removes comment blocks starting with // or /* */ as well as unnecessary whitespace between tokens. However it preserves newlines to protect automatic semicolon insertion. Strings and regular expressions remain untouched. Example: // add two numbers var x = 1 + 2; becomes var x=1+2;. The savings are measurable in characters and as a percentage.

What it can and cannot do

The minifier safely removes comments and collapsed whitespace. It does not change the semantics of your code and is therefore safe for production. However, it cannot rename variables, optimize the AST, or obfuscate code. For maximum compression combine the output with a named minifier or a build step.

Why local processing in the browser

Everything runs entirely in your browser. Your JavaScript code is not sent to or stored on a server. This means full GDPR compliance: no accounts, no sign-up, no data transmission. You can minify sensitive code without worrying about where it ends up.

A small contribution to climate action

Every minification on your device avoids a server request over the Internet. The process consumes only a fraction of the energy needed for a data transfer. The International Energy Agency estimates that data centers consumed about 415 terawatt-hours in 2024, roughly 1.5 percent of global electricity demand. Local tools reduce network traffic.

Frequently asked questions

Does the minifier change the code?

No. The minifier only removes comments and unnecessary whitespace. The semantics of the code remain completely unchanged.

What happens to newlines?

Newlines are preserved so automatic semicolon insertion cannot break your logic.

Can I convert the minified code back?

No. The minifier permanently removes information. You need the original code to reverse it.

Is my JavaScript data transmitted?

No. Minification runs entirely in your browser; your code is not transmitted.

Does it work with all JavaScript versions?

Yes. The minifier works with modern and older JavaScript syntax as long as the code is valid.

Do I need to be online?

No, after the page loads the tool works offline.