How to use HTML Formatter
What it does & when you need it
You've inherited a template that arrives as one endless line, or a server rendered a page with no whitespace and you need to see the structure before you can debug it. This tool does both halves of that job: Beautify re-indents raw markup into a readable tree so you can follow nesting at a glance, and Minify strips the comments and slack whitespace back out to shrink what you ship. It runs entirely in your browser, so a marketing page full of unreleased copy or an email template with customer tokens never touches a server.
Reach for it when you're diffing two versions of a component's output, cleaning up markup pasted from a CMS or a "view source", or trimming a static fragment before it goes over the wire. Because both directions are lossless in the ways that matter for rendering, you can round-trip freely: minify to measure payload, beautify to read, then minify again for production.
How to use
- Paste your markup into the input.html buffer, press Sample to load a
small nested document, or Upload an
.html/.htmfile. - Pick a mode. Beautify re-indents (choose a 2- or 4-space indent); Minify collapses the document to the smallest equivalent form. The output pane updates live as you type.
- Read the status bars: the input shows its byte size, and the output shows the
result size plus, in minify mode, the percentage saved. Press Copy result
or
Ctrl/Cmd+Enterto grab the output.
Things worth knowing
Inter-tag whitespace is not always safe to delete. The space between inline
elements like <a>, <span>, or <img> is significant — the browser renders it
as a real space, so removing it can push two words together or nudge your layout.
This minifier collapses that whitespace aggressively because that's the behavior
people usually want when squeezing a payload, but if you have a run of inline
elements separated only by spaces, eyeball the result before shipping it.
Void elements have no closing tag, and the formatter leaves them that way.
<br>, <img>, <input>, <meta>, <hr> and friends are self-closing by
definition in HTML — there is no </br>. A formatter that "helpfully" invents a
closing tag produces invalid markup, so beautifying only indents these; it never
adds a partner tag.
Some elements are preserved verbatim. The content of <pre>, <textarea>,
<script>, and <style> is whitespace-sensitive — a <pre> block is its
formatting, and reflowing a script can change strings or break it. The minifier
stashes those regions untouched and only compresses the markup around them. If you
need to tidy the CSS or JavaScript inside those blocks, run it through the dedicated
CSS Formatter or JS Formatter
instead.
The two modes serve opposite goals. Beautify optimizes for a human reader —
consistent indentation, one element per line. Minify optimizes for bytes on the
wire: it drops non-conditional comments and redundant whitespace, which shrinks the
file before gzip even gets to it (gzip handles repetition well, but there's no
reason to compress bytes you can simply delete). If you're hand-encoding special
characters rather than reshaping structure, the HTML Entities
tool is the better fit, and for rendered .md content try the
Markdown Preview.