JavaScript Minifier
Strip the comments and layout out of a script, without renaming a single thing inside it.
What this tool does
JavaScript Minifier reads your source character by character and removes what a browser never needed: // line comments, /* … */ blocks, the indentation at the front of every line and the blank lines between them. Quoted strings, template literals and regular expressions are recognised as they go past and copied through byte for byte, so a // sequence inside a URL string survives, and a template spanning three lines keeps all three.
What it does not do is the part worth reading first. Identifier renaming, dead-code removal and constant folding — the passes that make an uglify or terser build genuinely small — are all missing here, and two lines of code are never welded into one. That restraint is deliberate: a newline in JavaScript can be doing the work of a semicolon, and deleting one in front of a line that opens with a bracket quietly changes what the code means. So every line that carries code stays its own line, every name you chose survives, and the saving is comments and layout alone — substantial on a documented, four-space-indented file, close to nothing on one that arrived compact.
That makes this the wrong tool for a production bundle. A build step running esbuild, terser or Rollup will cut far more than this leaves, emit a source map so stack traces still point at real lines, and resolve your imports; none of that happens here. It earns its place where there is no build step to reach for — a snippet pasted into a template, a theme file edited in production, a script kept in a repository as one plain file — or when you want a smaller version you can still read and diff against the original.
Everything happens inside this browser tab. Paste the script, press Run, and nothing is uploaded; the page keeps working with the network off, which matters when the file names an internal endpoint or an unreleased feature. Two limits follow from scanning the source instead of parsing it. Whether a slash opens a regular expression or divides two numbers is judged from the character before it, not from any understanding of the expression. And JSX and TypeScript are not understood at all: a // in JSX text is read as a comment and takes the remainder of that line with it, while type annotations simply travel through, so TypeScript in is TypeScript out. Ordinary JavaScript is covered by the tool's own tests; anything unusual deserves a glance at the output before it ships.
How to use it
- Paste the script. Drop it into the JavaScript box, or press Load sample to see how a comment, a regular expression and a string containing // are each treated.
- Decide what the comments are worth. Keep /*! and @license comments is on by default, and @preserve counts as well, because stripping the banner a licence obliges you to carry is not a saving worth taking. Switch it off and every comment goes, banners included.
- Leave space collapsing on, or turn it off. Collapse runs of spaces and tabs squeezes padding used to align code — a column of assignments, say — down to a single space. Turn it off to keep that alignment intact; the indentation at the start of each line goes either way.
- Read the saving, then copy the result. Under the output box sit the before and after sizes in UTF-8 bytes and the percentage the pass removed, counted on the file you pasted. Copy output then puts the minified script on the clipboard; nothing is offered as a file.
Processing & privacy
Runs on your device. Your file is processed directly in this browser.
Common use cases
A snippet going straight into a page
Inline script in a template or a tag manager has no build behind it, so every note you wrote while developing is downloaded by every visitor until something removes it.
A theme or plugin file edited in place
Scripts shipped inside a WordPress theme are deployed as they are. Dropping the comment blocks and indentation shrinks them while leaving the function names you will need to read again next month.
A third-party file vendored into a repository
Keep the licence banner, lose the several hundred lines of API documentation above the code, and the file stays legal to redistribute and quicker to scan.
Measuring what a file is made of
Run it once and the before and after figures tell you what share of the source was comments and layout, which is a fair argument for or against adding a real build step.
Questions
Is my code uploaded anywhere?
Does it rename variables the way uglify does?
Why is the output not one long line?
What sort of saving should I expect?
Will it damage my regular expressions?
Where else can the scanner lose its place?
Does this replace a bundler?
Can I get the original back afterwards?
Related tools
- JSON Formatter — Pretty-print, collapse and inspect JSON instantly.
- Base64 Encoder Decoder — Encode and decode Base64 text and files.
- JWT Decoder — Inspect the header, payload and claims of a JWT.
- Hash Generator — Compute MD5, SHA-1, SHA-256 and SHA-512 digests.
- Regex Tester — Test patterns against sample text with live matches.
- Unix Timestamp Converter — Convert between epoch seconds and readable dates.