JavaScript Minifier

Minify JavaScript by removing comments and collapsing whitespace with a simple minifier.

Try an example

Load a ready-made sample into this tool and run it. Every result you see is calculated live by the tool itself — nothing here is a pre-written answer.

Sample: input: // Greet function greet(name) { return 'Hello...

How to Use

  1. Paste JavaScript code.
  2. Click Run.
  3. Copy the smaller code.

What this JavaScript minifier does

This JavaScript minifier makes scripts smaller by removing comments and collapsing whitespace with a simple minifier. Paste your code, run the tool, and copy the compact result for a project or a page. Variable names, logic and strings stay as written; the savings come from the spaces, line breaks and comments that JavaScript does not need in order to run.

When to use the minified output

Minified scripts download and parse faster, so they suit published pages, embedded snippets and anywhere file size is limited. Minify a copy at publishing time and keep your readable source for development, because stepping through compacted code while debugging is slow and frustrating for anyone who maintains the site later.

Good to know

This is a simple minifier, not a full parser. Code with tricky strings or regular expression literals may not survive the process intact, so always test the minified output before deploying it, and keep the original file as your fallback.

Frequently asked questions

Does minifying rename my variables?

No. This tool only removes comments and collapses whitespace; it does not shorten names, restructure code or bundle files. The output is your same script with the unnecessary spacing taken out, nothing more.

Why do I need to test the result?

The minifier works mechanically rather than parsing your code, so a string that looks like a comment can occasionally be cut by mistake. Test the output once and you will catch any problem early.

How much smaller will my file get?

It depends on how much commentary and spacing the original holds. Comment-heavy, loosely formatted code shrinks a lot; already tight code shrinks very little. The tool shows the result so you can compare sizes yourself.

How to use JavaScript Minifier

  1. Paste JavaScript code.
  2. Click Run.
  3. Copy the smaller code.

Limitations

This is a simple minifier: it is not a full parser, so code with tricky strings or regex literals may break; test before deploying.

Browse all tools · More Developer Tools tools

Scroll to Top