CSScompressor Nederlands

JavaScript minifier

Strip comments and whitespace from JavaScript without renaming anything. Deliberately conservative: it will not shorten your variable names, and it will not break your code.

Compression level

JavaScript is switched off. The button below still works: compression then happens on the server.

What this minifier does — and what it refuses to do

There are two kinds of JavaScript minifier. One parses your code into a full syntax tree, renames every local variable to a single letter, folds constants and drops unreachable branches. That is what Terser and esbuild do, and it is what you want in a real build pipeline.

This is the other kind: a careful whitespace and comment stripper. It removes line comments, block comments, indentation and blank lines, puts statements back together where that is provably safe, and stops there. Your identifiers keep their names. The result is typically 20 to 40 percent smaller than the original, where a full compiler might reach 60.

That trade is on purpose. A tool that renames variables has to understand your entire program — scopes, closures, eval, with, dynamic property access — and when it gets that wrong you get a bug that only shows up in production. A tool that only removes whitespace cannot make that mistake.

The parts that are easy to get wrong

When to use something heavier

If you ship an application bundle, use a real build tool: esbuild, Terser or whatever your bundler already includes. They mangle names, tree-shake unused exports and produce source maps. Use this page for the cases where that is overkill: a single script you paste into a page, a snippet for a client, a widget you hand to someone else, or a quick check of how much whitespace a file is carrying.

Does it rename my variables?

No, never. Identifiers are left exactly as they are. That is why the saving is smaller than a full compiler's, and why the output cannot break on a scoping edge case.

Will the output still work in older browsers?

It runs wherever your original ran. Minifying is not transpiling: no syntax is converted, so arrow functions stay arrow functions and let stays let. If you need old-browser support, run Babel or esbuild first.

Can I minify a module with import and export?

Yes. import and export statements are just code as far as this tool is concerned, so they pass through with their whitespace cleaned up.

Does it produce a source map?

No. Source maps need a full parse of the original and a record of every position change. If you need debugging support in production, use a bundler.

Other tools on this site

Read more