HTML Formatter & Minifier
Beautify messy HTML with clean indentation, or minify it and see the bytes saved.
The HTML Formatter beautifies raw or minified HTML with clean, consistent indentation, and minifies it back down for production — reporting exactly how many bytes you saved. The contents of pre, script and style tags are preserved so nothing breaks.
- ✓Beautify messy or minified HTML
- ✓Minify and see the bytes saved
- ✓Configurable 2 / 4 / 8-space indentation
- ✓100% private — runs in your browser
Beautify or Minify HTML
Paste raw or minified HTML and it's beautified with consistent indentation as you type. Click Minify to collapse whitespace and strip comments — the content of <pre>, <textarea>, <script> and <style> is preserved so nothing breaks. Everything runs locally in your browser.
How to Format HTML Online
- 1Paste raw, exported or minified HTML into the input panel
- 2Choose 2, 4 or 8-space indentation
- 3Click Format to beautify, or Minify to compress it
- 4Copy or download the result
Example
Input (single line):
<div class="card"><h2>Title</h2><p>Some <b>text</b> goes here.</p><ul><li>One</li><li>Two</li></ul></div>Output (formatted, 2 spaces):
<div class="card">
<h2>Title</h2>
<p>Some <b>text</b> goes here.</p>
<ul>
<li>One</li>
<li>Two</li>
</ul>
</div>Features
Clean indentation
Nested elements are consistently indented, however deep the markup goes.
Configurable indent size
Switch between 2, 4 or 8 spaces to match your project's style.
Preserves special tags
pre, textarea, script and style content is left exactly as-is — no accidental breakage.
Minify with bytes saved
Collapse whitespace and strip comments, and see exactly how much smaller the output is.
Keeps IE conditional comments
Standard comments are stripped on minify, but IE's [if ...] conditional comments are kept.
100% private
Formatting and minifying run entirely in your browser — nothing is uploaded.
Who Uses This
- ▸Frontend developers — clean up HTML exported from a design tool, CMS, or scraped from a live page before editing it.
- ▸Backend developers — format server-rendered templates (Django, Rails, PHP, JSP) that arrive as one long minified line.
- ▸Email developers — beautify table-based HTML email templates to make them readable during review.
- ▸DevOps and build pipelines — minify static HTML before deployment and confirm exactly how many bytes were saved.