Skip to content
Minify

Compression up to 70% with byte savings stats

Minify and beautify for HTML, CSS, JSON, XML. Typical 30-50% size reduction on HTML/CSS sources, up to 70% on pretty-printed JSON. Inline compression stats. For JavaScript you need an AST-based minifier (Terser, esbuild, swc) integrated in the build pipeline: this tool covers languages that can be handled with deterministic text-replacement rules.

How to use the minifier

  1. 1

    Paste the source

    HTML, CSS, JSON or XML. For HTML the tool preserves the content of <pre>, <textarea>, <script>, <style> intact (significant whitespace).

  2. 2

    Pick the action

    Minify strips comments and collapses whitespace. Beautify reformats with consistent indentation. Inverse functions: minify the beautify output and you get back an equivalent source.

  3. 3

    Check stats

    The status bar shows input size, output size, reduction/expansion percentage. Typical: HTML -30%, CSS -25%, JSON pretty -> minified -65%.

  4. 4

    Copy or re-process

    Copy for direct use. For build workflows (Webpack, Vite, esbuild), these minifiers are integrated in the toolchain: use the minifier here only for ad-hoc scripts or quick checks.

What it minifies and what it leaves alone

Languages covered. The minifier handles HTML, CSS, JSON and XML, the languages where whitespace and comment removal can be applied with deterministic text-replacement rules. For JavaScript, reliable reduction requires an AST parser (Terser, esbuild, swc) capable of variable renaming, dead code elimination and mangling: semantically complex transformations, out of scope for a lightweight utility and properly the responsibility of the build pipeline (Webpack, Vite, esbuild).

HTML preservation rules. The HTML minifier respects contexts where whitespace is significant: inside <pre>, <textarea>, <script>, <style> the content stays intact. Some more aggressive minifiers strip newlines inside <pre> breaking code samples, or strip whitespace inside <script> breaking multi-line template literals: these mistakes are prevented here.

Operational privacy. The HTML, CSS and JSON of a site under build can contain references to internal backends, database schema, API structure, dummy accounts or secrets in comments. The minification happens directly in the browser, avoiding the transfer of these sources to a third-party service for what is essentially a mechanical operation.

Glossary

Technical terms used on this page, briefly explained.

Minify #
Removal of non-significant whitespace, comments, indentation to reduce file size. Typically -20-50% bytes for HTML/CSS, -50-70% for pretty-printed JSON.
Beautify #
Inverse operation: re-indents and re-spaces a minified or badly formatted file to make it human-readable.
Significant whitespace #
Spaces/newlines that affect rendering or execution. Examples: inside <pre>, inside JS/CSS strings, in XML CDATA. The minifier respects these contexts.

Frequently asked questions

Why is there no JS minify?
To reliably reduce JS bytes you need an AST parser (Terser, esbuild, swc): transformations like variable renaming, dead code elimination and mangling require semantic understanding of the code. These are heavy libraries, normally integrated in a build pipeline (Webpack, Vite, esbuild). For ad-hoc minify from the terminal: npx terser file.js -c -m.
Does the CSS minifier collapse colors?
Partially: #aabbcc becomes #abc where possible (only if the three channels have both nibbles equal). Other micro-optimizations (unit removal on 0, rgba(0,0,0,1) -> #000 conversion) are not implemented to avoid breaking CSS edge cases.
Does HTML minify break rendering?
It should not. The tool preserves content of <pre>, <textarea>, <script>, <style>. Edge case: HTML with significant whitespace inline (e.g. <span>a</span> <span>b</span>) may become <span>a</span><span>b</span> with the two spans glued. For text layouts sensitive to whitespace, use beautify and review by hand.
Does it work offline?
Yes. Bookmark for offline use.
Does JSON minify handle JSON with comments (JSONC)?
No, JSON.parse rejects comments. For JSONC: strip comments with regex before pasting, or use a dedicated JSONC parser (Microsoft's jsonc-parser library for example).
Is there a size limit?
Nothing hardcoded. HTML/CSS/JSON files of 1-2 MB are comfortable. Beyond 10 MB the UI may slow down. For huge files: html-minifier-terser CLI.
Does XML beautify handle CDATA sections?
Treats <![CDATA[...]]> as a preservable element. Verify the result for complex cases (CDATA with internal text tags that the parser may confuse).

Who builds these tools?

Maurizio Fonte, senior IT consultant with 20+ years in PHP, Laravel, unmanaged Linux infrastructure, applied cybersecurity and AI/LLM integration. Production backends, legacy code modernization, security audits, custom AI agents and MCP servers: the work behind every tool published here.

About Maurizio Fonte