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

BUILT FOR THE DETAILS
  1. 01Add your input
  2. 02Inspect & adjust
  3. 03Use your result
Browse developer tools

Workspace

PixelOkay · Developer tools

Uses html-minifier-terser from a CDN. Test production markup, especially inline scripts, whitespace-sensitive content and templates.

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. Minify in a worker, inspect the output and copy or download it. 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 mode also removes redundant attributes. Empty-attribute removal is a separate opt-in engine setting; it is not a blanket promise that all empty values are irrelevant. Script and style contents are not separately minified by this tool.

Worked example

Input:
<div>  Hello world  </div><!-- build note -->
With comment removal enabled, the build note is removed.
Exact remaining spacing depends on the preset.

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.

Reference: HTML minifier options.

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