JavaScript Minifier

Minify JavaScript code to reduce file size.

JavaScript

Minified Output

Basic whitespace/comment minification. For production use, consider Terser or UglifyJS.

About the JavaScript Minifier

The JavaScript Minifier strips comments, indentation and redundant whitespace from a script so it downloads faster. Paste your code and copy the compressed result.

This is a whitespace-and-comments minifier, not a compiler. It does not rename variables, inline functions or tree-shake, which is what Terser or esbuild do. That makes it safe and predictable, but the savings are smaller: usually 20 to 40 per cent on readable source.

The one real hazard is automatic semicolon insertion. JavaScript lets you omit semicolons, and the parser inserts them by rule, but if a minifier joins two lines that relied on a line break, the meaning can change. Keep a copy of the readable source, and prefer a real bundler for production builds.

Common questions about JavaScript Minifier

Is minifying JavaScript safe?

For well-formed code with explicit semicolons, yes. Code relying on automatic semicolon insertion can break.

Does it rename variables?

No. That is what Terser and similar tools do. This only removes whitespace and comments.

How much smaller will it be?

Typically 20 to 40 per cent on readable source. Minified code barely changes.

Why did my script stop working after minifying?

Almost always a missing semicolon where a line break was doing the work. Add semicolons and try again.

Does it support modern syntax?

It treats the code as text, so any syntax survives as long as the whitespace rules hold.

Should I minify in production?

Yes, but through a build tool that also bundles and caches. Keep readable source in version control.

Related Tools in Developer Tools

JSON FormatterBase64 Encoder/DecoderURL Encoder/Decoder