HTML minifier / beautifier

Minify and beautify HTML

Paste any HTML — a fragment, a full page, or server-rendered markup.

Drop a file here

or paste HTML

This tool runs entirely in your browser. Your markup is never uploaded or sent to a server.

About this tool

HTML minification strips comments, whitespace, and unnecessary line breaks from markup without changing how the page renders, reducing file size and slightly speeding up parsing. The beautifier does the reverse — it takes minified, templated, or poorly formatted HTML and reformats it with consistent indentation based on element nesting, making it far easier to read and debug markup produced by a build tool, CMS, or another developer.

Common uses

  • › Minifying HTML before deploying to production
  • › Reducing markup size to improve page load scores
  • › Expanding minified or server-rendered HTML to understand its structure
  • › Cleaning up auto-generated or templated markup for review
  • › Inspecting the HTML output of a bundler or static site generator

Example

Input
<div class="card"><h2>Title</h2><p>Some text.</p></div>
Output
<div class="card">
  <h2>Title</h2>
  <p>Some text.</p>
</div>

Technical notes

  • › Minifying HTML does not minify inline <script> or <style> content beyond basic whitespace handling — use the JS or CSS tools separately for those.
  • › Beautifying does not validate HTML; unclosed tags or invalid nesting may format unpredictably rather than raise an error.
  • › Comments are stripped during minification, including conditional comments some older tools rely on — check output if you depend on those.

FAQ

Does minifying HTML break my page?

It shouldn't — minification only removes whitespace, comments, and line breaks that don't affect rendering. If something looks different, check for content that relied on whitespace (like <pre> blocks).

Will this minify the CSS and JavaScript inside my HTML?

Only lightly. For thorough minification of embedded <style> or <script> blocks, run that content through the CSS minifier or JS minifier separately.

Why did beautifying produce oddly nested output?

The beautifier indents based on tag nesting, so unclosed or mismatched tags in the source can throw off the indentation of everything after them.

Related tools