Skip to main content

JavaScript Minifier Online: Compress JS by Removing Comments & Whitespace

Paste JavaScript and get minified code instantly. This minifier strips comments, blank lines, and extra whitespace, then shows your byte savings. Free, 100% in-browser.

JavaScript Input
0 chars
Minified JavaScript
0 chars

Instant Processing

Minify your JavaScript in real-time as you paste or type code.

Size Reduction

See exactly how many bytes you save with detailed compression statistics.

100% Private

All processing happens locally. Your code never leaves your browser.

JavaScript Minifier: Compress JS by Stripping Comments and Whitespace

A JavaScript minifier removes the characters a browser ignores — comments, blank lines, indentation, and extra spaces — so the file is smaller and downloads faster. Paste JavaScript on the left and the minified code appears on the right, with the original size, new size, and percent saved. It runs 100% in your browser, free, with no upload.

How to minify JavaScript

  1. Paste your JavaScript into the JavaScript Input panel, or click Example to load a sample script.
  2. The Minified JavaScript output updates instantly — there is no Minify button to press.
  3. Read the stats bar above the output for original size, minified size, and the exact percent saved.
  4. Click Copy to put the minified code on your clipboard, or Download to save it as toolk-minified.js.
  5. Use Clear (the trash icon) to reset both panels and start over.

How JavaScript minification works

Minification reduces file size without changing behavior. Across most real-world bundles, whitespace removal and identifier mangling account for roughly 95% of the savings — not exotic code transforms. Production tools such as Terser parse your code into an Abstract Syntax Tree, then mangle local variable names, fold constants, and run dead-code elimination, reaching reductions up to about 80%.

This Toolk minifier is the lightweight, browser-side tier of that pipeline. It performs safe textual minification only: it deletes // line comments and /* */ block comments, removes blank lines and indentation, collapses repeated spaces and tabs, and strips most spaces around operators — while preserving the spaces that keywords like return, typeof, and const require. It does not rename variables or remove unused code, so the output stays recognizable.

"Minification removes whitespace, comments, and redundant characters while variable names stay the same; uglification goes further by renaming variables and functions to the shortest possible names."— The distinction this tool follows: it minifies, it does not mangle.

One detail build tools add that this one removes: a source map comment. Bundlers append a //# sourceMappingURL=app.js.map line so DevTools can map minified code back to your source (see the MDN source map glossary). Because this minifier strips all comments, any sourceMappingURL or /*! license */ banner is removed too — add those after minifying.

Worked examples: input → output

Comment + whitespace removal

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

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

Block comment dropped

/* config */ const MAX = 100;

const MAX=100;

Edge case · comment marker inside a string

The comment stripper is regex-based, not a parser. A // inside a string literal — for example const note = "visit example.com // now"; — gets cut from // onward, breaking the string. A leading https:// is protected (the regex skips // after a colon), but other in-string or in-regex // sequences are not. Review output that contains // inside strings or regex literals.

What this minifier does — and what it leaves alone

These rows reflect the actual transforms in this tool, contrasted with a full AST compressor like Terser. Use it to decide whether browser-side minification is enough or you need a build step.

TransformThis Toolk minifierAST tool (Terser)
Line & block commentsRemovedRemoved
Whitespace & blank linesRemovedRemoved
Spaces around operatorsCollapsedCollapsed
Identifier / variable manglingNot doneDone
Dead-code eliminationNot doneDone
Typical raw size cut~20–60%up to ~80%

Minification and Gzip/Brotli are not the same job

Minifying is not a substitute for server compression — the two stack. Minification rewrites the source to fewer bytes; Gzip and Brotli then compress those bytes in transit and the browser decompresses them. Minified JavaScript actually compresses better, because there is less redundant whitespace for the algorithm to encode. In practice, minify + Brotli (or Gzip) can shrink a payload by roughly 80–90% versus the original source, and Brotli typically beats Gzip by about 15–20%.

Practical takeaway: use this tool for quick, transparent comment-and-whitespace minification, keep server compression on, and reach for a build-time AST tool only when you need identifier mangling or dead-code elimination. The savings figure shown here is raw bytes (measured as the UTF-8 Blob size), so your over-the-wire number after Brotli will be smaller still.

Runs 100% in your browser

Your code never leaves your device. Minification happens locally in JavaScript, and Copy and Download use your browser's native APIs — no uploads, nothing leaves your device, and it keeps working offline. I tested this against the built-in Example, heavily commented ES6 modules with arrow functions, classes, and template literals, and intentional edge cases such as // markers inside strings. Comment and whitespace removal is reliable; just review output that embeds // inside string or regex literals before shipping.

Frequently asked questions

Is this JavaScript minifier free?

Yes — 100% free with no signup and no usage cap. Paste any amount of JavaScript, minify it instantly, then copy or download the result as toolk-minified.js.

Does my code get uploaded anywhere?

No. Everything runs in your browser with JavaScript, so your source never reaches a server. The tool works offline once the page has loaded.

Does it mangle variable names or remove unused code?

No. This is a comment-and-whitespace minifier, not an AST compressor. It never renames identifiers or eliminates dead code. For mangling and dead-code elimination, use a build-time tool like Terser.

Will minifying break my code?

Usually no, but because it is regex-based, a // inside a string or regex literal can be stripped, and spacing changes around division can affect regex literals. Test the output before shipping anything critical.

Last updated: June 2, 2026 · Runs 100% in your browser — no uploads, nothing leaves your device.

Need a different tool?

Browse all 89 free, in-browser tools — or tell us what we should build next.

Browse all tools