Developer Tools

JavaScript Minifier

Strip comments and unnecessary whitespace from your JavaScript to reduce its file size before shipping it.

Size comparison will appear here after minifying.
Advertisement space

How JavaScript Minifier Works

The minifier removes // and /* */ comments and collapses whitespace, while identifying strings, template literals and regular expressions so their contents are never touched. It keeps a single space between words where removing it would merge two tokens together, so the code keeps running exactly as before.

How to Use This Tool

  1. Paste your JavaScript into the input box.
  2. Select Minify JavaScript.
  3. Copy the compact result and check the size reduction shown below it.

Example

Input:

function add(a, b) {
  // sums two numbers
  return a + b;
}

Minified output: function add(a,b){return a+b;}

Helpful Tips

  • Keep an unminified copy for development — this tool focuses on safely stripping comments and whitespace rather than renaming variables, so readability is the main thing lost.
  • Always test minified code before deploying it, the same as with any build step.

Frequently Asked Questions

Does this rename variables or functions to shrink the code further?
No. It only removes comments and unnecessary whitespace, which keeps the minification safe without a full parser — it doesn't shorten identifiers.
Could minifying break my code?
The tool is built to leave strings, template literals, regular expressions and comment content completely untouched, and never removes whitespace where doing so would merge two words together.
Is my code uploaded anywhere?
No, minifying happens entirely in your browser.

This tool runs entirely in your browser. Your input is not uploaded to any server.