Skip to developer tool
DEVELOPER TOOLKIT CODE & FORMATTING

HTML Minifier & Compressor

Create compact HTML while retaining a readable source copy. Choose conservative whitespace behavior or standard optimization, then review parser output and byte counts before downloading.

Browser-based · No account required · Copy and export

LOCAL FIRST · HTML SOURCE OPTIMIZATION

Optimization workbench

Paste markup, review exact edits, export a separate HTML file. Input is never executed or uploaded.

Source → Review → Export

Conservative retains text-node content, changes whitespace-only gaps to one space and can remove ordinary comments. Review all published outputs.

Drop one local HTML file here, or use the file picker. No upload occurs.
Ready. Choose a profile and run locally.
—Input UTF-8 bytes
—Output UTF-8 bytes
—Byte difference
—Processing time
Inspect changes and publishing risks

Original excerpt

Optimized excerpt

Excerpts are bounded for readability. This is not a browser rendering or semantic equivalence test.

Review checklist

  • Run a conversion to see applicable warnings.
Recipe import/export

Recipes store your profile and options, never the HTML source.

Batch HTML publishing

Choose up to 12 local HTML files (max 4 MiB each); process sequentially and download a ZIP with a measured manifest.

ZIP · report · HTML files
No files selected.
FileInputOutputResultDownload
BUILT FOR THE DETAILS
  1. 01Add your input
  2. 02Inspect & adjust
  3. 03Use your result
Browse developer tools

How to use HTML Minifier & Compressor

  1. Paste an HTML document or load a local file. Set the desired output filename.
  2. Choose the preset, comment-removal option and optional empty-attribute removal. Start conservatively when whitespace affects inline content.
  3. Run the local tokenizer in a Worker when available, then inspect and copy or download the result. Test the generated document in its actual layout.

When to use this tool

Prepare an HTML fragment or page for a build while controlling whitespace and comment removal. Check inline text, preformatted content and templates after minifying.

Whitespace can affect rendered HTML

Whitespace between inline elements can be visible. Conservative mode keeps a collapsed space where appropriate instead of treating every separator as disposable. Standard additionally collapses ordinary text whitespace and does not remove attributes automatically. Empty class/title removal is a separate opt-in setting; it is not a blanket promise that all empty values are irrelevant. Script and style contents are not separately minified by this tool. This local tokenizer is intentionally more limited than a full HTML5 parser and does not certify runtime equivalence.

Worked example

Input:
<div>  Hello world  </div><!-- build note -->
With comment removal enabled, the build note is removed.
Conservative retains text content and converts whitespace-only inter-tag gaps to one ASCII space; Standard also collapses runs in ordinary text nodes.

Keep visible spaces between inline elements

<p><span>Read</span> <strong>more</strong></p>
<!-- Example build note -->
  1. Use this authored fragment to review the separator in Read more. Start with Conservative and decide whether comments should be removed.
  2. Compare inline spaces and preformatted content. Source length alone does not tell you whether visible text still reads correctly.
  3. Consider Standard and empty-attribute removal separately. A template or application hook can give particular attributes/comments a purpose.
  4. Download a separate copy and review it in its actual destination. The tool does not compile server templates or provide an execution preview.

Inline scripts and styles are retained rather than separately minified. Minification is not sanitization or accessibility validation.

Original markup, not a rendered result. Use CSS Minifier and JavaScript Minifier for those separate languages.

Limits and output checks

Minification is not HTML sanitization, accessibility validation or template compilation. The output is not executed or inserted as a live page preview. Server templates and unusual embedded languages need separate testing. Byte statistics exclude gzip/Brotli and do not predict an equal page-load improvement.

V2 uses a local bounded tokenizer, not the html-minifier-terser CDN. It cannot guarantee HTML5 parser equivalence or compile templates.

Frequently asked questions

Does it remove every kind of comment safely?

Comment removal is an explicit option. Keep required notices and review template or conditional-comment workflows before publishing.

Does it compress inline JavaScript and CSS?

No. Their text is retained rather than passed through another minifier in this page.

Can I restore the exact original formatting?

No. Keep the original source under version control. Formatting changes and removed comments cannot be reconstructed from minified output.

Reduce markup without replacing the original

Choose explicit whitespace and comment options, then compare the generated markup with the source. Retain notices and template syntax required by the destination.

Scope of this workflow

This is not sanitization or template compilation. Inline JavaScript and CSS are retained rather than separately minified.

Code Beautifier Online - JS, JSON, HTML & CSS · All developer tools · Privacy policy · Contact PixelOkay