TapCub is live — analytics, insights and live chat, free on one platform

Free tool JavaScript minifier, plus CSS and HTML

Paste a script, a stylesheet or a page. The minifier strips what browsers do not need, shows the byte count before and after, and measures both with gzip — the size that actually crosses the network when your server compresses text.

  • JS, CSS and HTML
  • Real gzip size
  • Runs locally
Minifier

Minify and compare sizes

The sample is a small tracking script for a pricing page. Switch language with the buttons below or paste your own code; results update as you type.

Paste code or open a file. Files stay on this device.

Saved 54.7% of the raw size and 42.9% after gzip.

Original (bytes)

1,414

UTF-8 size of what you pasted.

Minified (bytes)

641

UTF-8 size of the result.

Original, gzip

702

Measured with your browser's gzip (level 6).

Minified, gzip

401

Roughly what is transferred when the server compresses.

Minified JavaScript
/*! pricing-events.js v1.3 | MIT License */
(function(){"use strict";var t="[data-plan]";var e="monthly";function n(t){var e=t.querySelector(".price");var n=e?Number(e.textContent.replace(/[^0-9.]/g,"")):0;return n||0}function a(t,e){if(window.tapcub&&typeof window.tapcub.track==="function"){window.tapcub.track(t,e)}}document.addEventListener("change",function(t){if(t.target.name==="billing"){e=t.target.value;a("billing_toggle",{period:e})}});document.addEventListener("click",function(r){var i=r.target.closest(t);if(!i||!r.target.closest("button"))return;a("plan_selected",{plan:i.getAttribute("data-plan"),period:e,price:n(i)})})})();
Runs entirely in your browser. Nothing you type here is uploaded or stored by TapCub.

Version v1.0Updated Update history

Read the result

Four numbers, two questions

The raw sizes tell you what minification removed. The gzip sizes tell you what a visitor saves, because servers and CDNs normally compress text before sending it.

Original and minified

UTF-8 bytes of the text before and after. In the JavaScript sample, comments, indentation and long local names make up 54.7% of the file, which is why the raw saving looks large. Non-English comments weigh more: most Chinese characters take 3 bytes each.

The two gzip sizes

gzip finds repeated text and replaces it with short references, so whitespace and long repeated names were already cheap. Compare the two gzip numbers, not the raw ones, when you want to know what minifying is worth on the wire. Brotli, which many CDNs use, usually ends up a little smaller still.

Why the gzip saving is smaller

Minifying and compressing go after some of the same redundancy. In the CSS example, the raw size drops by 25.8% but the gzip size only by 15.8%. Do both: they are cumulative, just not additive.

Checks

Syntax errors stop the JavaScript minifier and point to the line and column. For CSS and HTML the result is still produced, with unclosed comments, braces or tags listed so you can fix the source.

Sizes are measured on this page: raw bytes with UTF-8, gzip with the browser's own CompressionStream at the default level. A server set to a different level, or using Brotli, will send a slightly different number of bytes.

How to use it

Three steps

Nothing to install and nothing uploaded.

  1. 1

    Pick the language

    Choose JavaScript, CSS or HTML, then paste the code or open a file. The example buttons load a script, a stylesheet and a page.

  2. 2

    Set the options

    Keep local renaming on for JavaScript; turn on top-level renaming only for code nobody else calls by name. Keep license comments if the code includes third-party libraries.

  3. 3

    Copy or download

    Copy the result or download it as .min.js, .min.css or .min.html. Keep the original: minified files are for shipping, not for editing.

What changes

What each minifier removes, and what it leaves alone

All three are conservative: they only make changes that cannot alter how the code runs or how the page renders, with the exceptions noted in the options.

  • JavaScript is parsed by terser 5.51.2 (parser, name mangler and printer), so the output is always syntactically valid
  • There is no "compress" pass: dead code, constant folding and console calls stay as written. Build tools such as terser or esbuild do that in your pipeline
  • CSS and HTML minifying is pattern-based: it never merges rules, rewrites colours or drops optional closing tags
What the minifier removes and keeps, by language
LanguageRemoved or shortenedKept as written
JavaScriptWhitespace, line breaks, comments; local variable and parameter names; quotes normalisedGlobal names, object properties, string contents, license comments (option)
CSSWhitespace, comments, the last ; in a block, the 0 in 0.5Selector spaces (div :hover ≠ div:hover), spaces in calc(), strings, url()
HTMLComments, whitespace between block elements, repeated spaces in text, type="text/javascript", checked="checked" → checkedEverything inside <pre> and <textarea>, one space between inline elements, IE conditional comments, attribute quotes
HTML, inline<style> and style="" as CSS; <script> as JavaScript (no renaming); JSON-LD re-serialised on one lineScripts with src, templates and unknown script types
Worked example

The three samples, measured

Each example button loads one of these files. The numbers below come from the same code that runs in the tool.

Size of the sample files before and after minifying, raw and with gzip (bytes)
SampleOriginalMinifiedSavedOriginal, gzipMinified, gzipSaved after gzip
JavaScript, local names renamed1,41464154.7%70240142.9%
JavaScript, whitespace and comments only1,414866—702467—
CSS88165425.8%48640915.8%
HTML with inline CSS, JS and JSON-LD1,6191,09932.1%87468521.6%

Renaming local variables is what separates a JavaScript minifier from a whitespace stripper: compare the first two rows. Files this small are dominated by gzip's fixed overhead of about 20 bytes, so savings on real bundles of tens of kilobytes are usually more stable.

Common mistakes

Where minified code goes wrong

Minifying is safe when it happens at the right time and with the right options.

Editing the minified copy

Keep the readable source in version control and minify on the way out, ideally in your build step with a source map. A hand-edited .min.js drifts from its source and is impossible to review.

Renaming names others depend on

Top-level renaming breaks functions that inline onclick attributes, other scripts or a tag manager call by name. Leave it off unless the file is fully self-contained.

Gaps that disappear

Whitespace between block elements is removed. If your CSS turns list items or cards into inline-block, the gap the browser used to draw between them goes too; use gap or margins instead of relying on source whitespace.

Expecting minification to fix speed

Smaller files download faster, but a heavy script still has to run. Render-blocking scripts, large images and long tasks usually cost more than a few kilobytes of whitespace. Load third-party scripts with defer or async.

FAQ

Minifier questions

Still have a question?

Chat with the team behind TapCub — we usually reply within a few hours on business days.

What does a JavaScript minifier do?

It removes whitespace, line breaks and comments, and shortens local variable and parameter names, without changing what the code does. This one uses terser's parser and name mangler, so a file that does not parse is reported with the line and column instead of being mangled.

How much smaller will my CSS or HTML get?

It depends on how much indentation and how many comments the source has, so there is no typical percentage worth quoting. The examples above lost 25.8% (CSS), 32.1% (HTML) and 54.7% (JavaScript) of their raw size. After gzip the saving is smaller, so look at the gzip columns for what visitors actually download.

Is minifying the same as gzip or Brotli compression?

No. Minifying rewrites the file so it is smaller but still valid code; compression encodes the bytes for transfer and the browser decodes them back. They stack: a minified file also compresses smaller, just by less than the raw numbers suggest.

Can minifying break my code?

Removing whitespace and renaming local variables does not change behaviour. The risky option is top-level renaming, which breaks code that other scripts call by name. For HTML, whitespace between inline-block elements disappears. Test the minified file before shipping it.

Why is there no option to remove console.log or dead code?

Those are compression transforms that need full program analysis, which would make the tool several times larger to load. Do it in your build: terser and esbuild both can drop console calls and unreachable code.

Does minifying help Core Web Vitals?

Indirectly. Smaller CSS and scripts in the critical path can bring LCP forward, and less JavaScript to parse can help INP, but render-blocking resources and long tasks usually matter more. Measure LCP and INP on real visitors before and after the change.

Is my code uploaded?

No. Minifying and the gzip measurement run in your browser; the JavaScript minifier is downloaded once from tapcub.com and runs locally. There is no share link, so pasted code never ends up in a URL.

How do I minify JSON?

This tool does not take JSON on its own. Paste it into the JSON formatter and choose “Minify (one line)”: it validates the JSON first and reports the line and column of any error. JSON-LD inside an HTML page is put on one line here when you minify the HTML.

Changelog

Update history

New features, fixes and data refreshes for this tool, newest first.

  1. · v1.0

    LaunchedFirst release.

Missing something or found an error? Tell us — requests that come up often go into the next update. All tool updates

See your data clearly. Find your growth.

Every click, backed by data. Install one line of code and see your first numbers in a minute.

No credit card · Free plans for analytics and chat · Cookieless analytics