This tool runs entirely in your browser. Nothing you paste is uploaded.
How you can check →JavaScript Minifier
Text & DataMinify or beautify JavaScript in your browser. Minifying runs a vendored, hash-pinned Terser for real mangling; beautifying uses this site's own token-level reprinter. Both run in your tab, never on a server.
Minifying is powered by Terser 5.51.2,
BSD-2-Clause, vendored at /vendor/terser/ and loaded from this site's own server —
never a third-party CDN.
Files, in this order
The minified JavaScript appears here.
No network activity while you use this tool Show the numbers
- Requests to any other server
- 0
- Requests since you started typing
- —
- Same-origin requests
- 0
Counted live by your browser's own Performance Timeline — the same data the DevTools Network panel reads. It cannot see what a browser extension does, and it is not meant to replace checking for yourself: here is how, in thirty seconds .
Minified or gzipped — which number matters?
Every JavaScript minifier reports raw bytes saved, and no browser has ever downloaded raw
bytes — real transport runs through gzip or brotli first. Unlike CSS, JavaScript minification
genuinely earns its keep after gzip too, because renaming variables removes redundancy gzip
cannot reach on its own. Measured: jQuery 3.7.1 goes from 285,314 to 87,533 bytes raw with
Terser's compress and mangle (69.3% smaller), and after gzip the gap is still 83,890 versus
30,406 bytes — a 63.8% saving. bootstrap.bundle.js shows the same pattern: 61.2%
smaller raw, 46.2% smaller gzipped. Compare that to CSS, where minifying Bootstrap's
stylesheet saves 17.2% raw but only 7.4% once gzip runs — gzip was already eating most of that
redundancy. The Size tab on this page measures both numbers for your actual file, with
CompressionStream, never estimated.
What this minifier will not do to your file
This page's own written code is a tokenizer and a token-level beautifier
(src/lib/tools/minify/js/tokenize.ts and format.ts) — the actual
minifying is done by a vendored copy of
Terser 5.51.2, loaded from this
site's own server and hash-pinned so it cannot silently change. That distinction matters
because the hard correctness questions in JavaScript minification — Automatic Semicolon
Insertion making a bare return followed by a newline mean something different
from return followed by an expression, or a private class field like
#count needing to be renamed consistently everywhere it is referenced without
colliding with another private name — require real scope analysis. Measured against this
page's own fixture: Terser reads a return statement's trailing newline as ending
the function, exactly per the specification, and renames #count to a new private
name everywhere it is used, never treating the # as separable from the name that
follows it. A hand-written, regex-based minifier that got either of these wrong would ship
broken code with no warning.
Licence comments are the other correctness question this page takes seriously: a
/*! ... */ or /** @license ... */ marker is a legal object under
MIT, BSD and Apache licences, and this tool keeps them by default — mapped onto Terser's own
comments: "some" mode — rather than stripping every comment as a blanket default.
Minification is not obfuscation
Minified JavaScript is trivially beautified back — this page's own Beautify mode does exactly that, restoring indentation and line structure from the token stream — so mangling variable names provides no real secrecy for proprietary logic. It is also not compression: gzip and brotli do the actual byte-shrinking work at transport time, and Terser's job is to remove redundancy (long names, dead code, whitespace) before compression even starts. What minification genuinely buys you, especially for JavaScript, is removing redundancy that compression cannot reach on its own — see the gzip section above for the measured difference that makes.
Common use cases
- Shrinking a script or a small bundle before shipping it, with licence notices intact
- Combining several JavaScript files into one, minified together, in a stated order
- Checking whether a mangled build still parses cleanly before it ships
- Reading a minified third-party script by beautifying it first
- Seeing which Terser setting — compress, mangle, or comment handling — earned which bytes
Frequently asked questions
- Which minifier does this use?
- Terser 5.51.2, vendored and hash-pinned — not a hand-written engine. Unlike this site's CSS and HTML minifiers, which are hand-written parsers built for this site, name mangling requires real scope analysis, and a subtly wrong hand-written mangler would ship broken code to a production site. Terser is loaded from this site's own server (never a third-party CDN) only after you interact with the input, and its bundle's SHA-256 hash is pinned by a test so it cannot silently drift.
- Is it safe to remove comments from JavaScript?
- Ordinary comments, yes. Licence comments — /*! ... */ or /** @license ... */ — are a legal object: MIT, BSD and Apache all require the notice to travel with the code. This tool keeps licence comments by default (mapped onto Terser's own comments:"some" mode) and only drops them if you turn that option off.
- Why is my minified file barely smaller after gzip?
- It depends heavily on what kind of file it is. Measured on jQuery 3.7.1: minifying with Terser's compress and mangle takes 285,314 bytes down to 87,533 raw, and after gzip the saving is still 63.8% — genuinely transformative, because renaming variables removes redundancy gzip cannot reach. CSS and already-repetitive markup often see a much smaller gzip saving because gzip was already compressing the whitespace away for free. The Size tab shows both numbers for your actual file.
- Can I get my original code back from a minified file?
- Structurally, yes — the Beautify mode re-indents a minified file into readable JavaScript, using this site's own token-level beautifier (not Terser). What does not come back is anything a minifier is designed to discard: original variable and function names once mangled, comments, and your exact formatting choices. If the minified file references a `//# sourceMappingURL`, this page detects it and lets you keep or drop that comment, but it does not read the map to restore the original source — that is a larger, separate capability this site has deliberately not built yet.
- Does this upload my JavaScript anywhere?
- No. Minifying and beautifying both run in this tab's own JavaScript — Terser executes in a Web Worker inside your browser, not on a server. The one network request this page makes is for Terser's own engine file, fetched from this site's own server the first time you interact with the input; it is not your code, and the privacy receipt below the tool names that request explicitly so the claim is checkable rather than asserted.
- Does minifying JavaScript preserve ASI-sensitive newlines and private class fields?
- Yes — that correctness burden falls on Terser, not on this site's own code, and it is exactly why D1 chose a real, widely used parser over a hand-written one. Measured: Terser correctly reads a bare `return` followed by a newline as ending the function (Automatic Semicolon Insertion), and correctly renames `#p` to a new private name without ever corrupting `this.#p` or colliding with an existing `#a`. A regex- or token-based minifier gets both of these wrong in ways that silently change what the code does.