Developer Tools

Minify JS

Quickly strip comments and whitespace from JavaScript to estimate and reduce its size. Paste your code and the minified version appears instantly with a live size-saved percentage. This is a lightweight minifier for snippets and quick checks, for production builds, use a full compiler like Terser or esbuild.

function calculateSum(a,b){const result=a+b;return result;}const x=10;const y=20;console.log(calculateSum(x,y));
This is a basic minifier. For production, use a full minifier like Terser or esbuild.

What minified JavaScript looks like

Minifying JavaScript goes further than minifying CSS: as well as stripping whitespace and comments, it can safely rename local variables, because nothing outside the function can refer to them.

Before — 134 bytes

// Sum a list of prices
function totalPrice(itemList) {
    let runningTotal = 0;
    for (const item of itemList) {
        runningTotal += item.price;
    }
    return runningTotal;
}

After — 74 bytes

function totalPrice(t){let n=0;for(const o of t)n+=o.price;return n}

Note what did not change: totalPrice keeps its name because it is exported and other code may call it, and .price keeps its name because it is an object property that could be accessed dynamically. Only the local itemList, runningTotal and item are shortened.

Minify, gzip and Brotli are not the same thing

These three are often treated as alternatives. They are not - they stack, and using all three gives a smaller result than any one alone.

MinificationgzipBrotli
What it changesRewrites the source to be shorterCompresses the bytes in transitCompresses the bytes in transit
When it happensBuild time, onceEvery response, by the serverEvery response, by the server
What the browser receivesShorter sourceCompressed bytes, decompressed on arrivalCompressed bytes, decompressed on arrival
Helps parse timeYes - there is genuinely less to parseNo - the file is identical once decompressedNo - the file is identical once decompressed
Typical extra saving20–40% on unminified JavaScript70–80% on textRoughly 15–20% better than gzip

The order matters: minify first, then let the server compress. Minification is the only one of the three that reduces work for the browser’s parser, because gzip and Brotli hand over exactly the same javascript they were given once decompression finishes. Compression is usually already switched on at the CDN, which is why minifying is the step most likely to be missing.

What does minifying JavaScript do?

Minifying JavaScript strips whitespace, comments, and shortens local variable names without changing how the code behaves, commonly cutting 30–50% of an unminified file before gzip. Smaller scripts download and parse faster, which improves both page load and interaction responsiveness on slower devices.

Runs in your browser. Your files and text never leave your device - nothing is uploaded.