πŸ—œοΈ HTML / CSS / JS Minifier

Strip comments and collapse whitespace to shrink your code. See the before/after byte savings live. Runs entirely in your browser β€” nothing is uploaded.

Input 0 chars Β· 0 B
Minified output
Copied

About Code Minifier

Code Minifier strips redundant characters β€” whitespace, comments, unnecessary tokens β€” from HTML, CSS, and JavaScript to reduce file size. Smaller files load faster, use less bandwidth, and often improve Lighthouse / PageSpeed scores. Three languages are handled with language-specific rules so the output stays syntactically valid.

Everything runs client-side. Your source code is never uploaded β€” safe for confidential markup, internal stylesheets, or scripts under NDA. Paste, click Minify, copy the result.

Basic minification only. This tool performs safe, universal transformations (strip comments, collapse whitespace). For maximum compression, use a build-time tool like terser (JS), cssnano (CSS), or html-minifier-terser (HTML) which perform advanced tree-shaking and identifier mangling.

How to use

1

Pick a language

HTML, CSS, or JavaScript β€” each has its own minification rules.

2

Paste your code

Or click "Load sample" to try it with example code.

3

Click Minify

The output panel shows the compact result plus the size savings badge.

4

Copy or download

Paste into your codebase, or download as a file with the right extension.

Key Features

Language-specific minifiers

HTML: strips comments, collapses inter-tag whitespace, preserves content inside <pre>, <textarea>, <script>, <style>, and <code> tags. CSS: strips /* */ comments, collapses whitespace, tightens around braces, colons, semicolons, and commas. JavaScript: strips // and /* */ comments (string- and regex-safe), collapses whitespace.

Toggle options for HTML

Strip comments β€” remove all HTML comments. Keep IE conditionals β€” preserve <!--[if IE]>...<![endif]--> for legacy sites. Preserve newlines β€” keep line breaks between tags (still safe, slightly larger output).

Live savings badge

See exactly how many bytes and what percentage you saved. Small savings on a single file compound across a whole site.

Copy + Download with correct extension

Copy to clipboard, or download as .html / .css / .js based on the active tab.

Common Use Cases

  • Quick minification of email templates before sending
  • Compressing inline CSS/JS in a CMS entry
  • Shrinking a static HTML file for a landing page test
  • Reducing size of legacy scripts that skip a build step
  • Cleaning up handwritten CSS before pasting into a stylesheet
  • Testing how minification affects a specific snippet before adding to production
  • One-off compression for A/B test variants
  • Comparing source vs minified size for a Lighthouse report

Security & Privacy

  • 100% client-side: minification runs in your browser. No source ever leaves your device.
  • Works offline: once the page loads, disconnect and it still works.
  • No account, no logging: use freely for confidential or NDA-covered code.
  • Basic rules only: the transformations here are conservative β€” they never mangle identifiers, dead-code eliminate, or reorder anything. What comes out is functionally identical to what went in.

Frequently Asked Questions

Depends heavily on the source. Well-formatted HTML with lots of comments and indentation often shrinks 20–40%. CSS with normal formatting shrinks 15–30%. Already-compact code sees smaller gains.
The JS minifier only strips comments and collapses whitespace β€” it doesn't mangle identifiers or restructure code. It respects string literals and regex literals so those aren't touched. That said, missing semicolons in your source (ASI-reliant code) can cause bugs after whitespace collapse. If you rely on ASI, keep newlines with the "Preserve newlines" option (HTML tab only, but you can use a real bundler for JS if worried).
For production apps, yes β€” use vite, webpack, or esbuild with proper minifiers (Terser, cssnano, html-minifier-terser). This tool is for one-off situations: quick email templates, CMS pastes, legacy code, or when you don't have a build pipeline.
Yes. Content inside <pre>, <textarea>, <script>, <style>, and <code> is preserved verbatim so their meaningful whitespace isn't destroyed.
No. All processing is in-browser JavaScript. Verify with DevTools β†’ Network. You can even disconnect from the internet after page load and the tool still works.
Yes β€” no signup, no ads, no limits.