JavaScript Minifier

Optimize your JavaScript by removing unnecessary comments and whitespace. Reduce your script's payload size and improve execution speed in just one click.

Minified output will appear here...

About the JS Minifier

Paste JavaScript and get a compact version without comments and unnecessary whitespace, useful for quick snippets, bookmarklets and embeds.

Everything you enter is processed in your browser; nothing is uploaded or stored.

How to use it

  1. Paste your script into Input JavaScript.
  2. Copy the code from Minified Result.
  3. Test the minified script once before using it in production.

What this JavaScript minifier does

It removes // line comments and /* block */ comments, collapses whitespace and newlines, and trims spaces around operators and punctuation where JavaScript does not need them.

It does not rename variables or rewrite code the way build tools such as Terser or esbuild do. That keeps it safe for small scripts, but for an application bundle a build tool will produce smaller output.

Example

function greet(name) { // say hi console.log("Hi " + name); } becomes function greet(name){console.log("Hi "+name);}.

Tips

  • End statements with semicolons before minifying: code that relies on automatic semicolon insertion can break when lines are joined.
  • Strings and regular expressions that contain // or /* need a quick check after minifying.

Frequently asked questions

Is JavaScript minification safe?

For code with semicolons, yes – only comments and whitespace are removed. Always run the minified script once to be sure.

What is the difference between minify and uglify?

Minifying removes unneeded characters. Uglifying (mangling) also shortens variable names; this tool only minifies.

Can I minify JSON here?

Use the JSON Minifier instead; it validates the JSON while compacting it.