Code & data
HTML Formatter & Minifier
Tidy up messy HTML with consistent indentation, or minify it for production. Runs in your browser, no upload required.
Runs entirely in your browser. Nothing is uploaded.
Formatted HTML appears here. What this tool does
Paste HTML that's been minified, generated by a template engine, or just written
inconsistently, and get it back with clean, readable indentation. Block-level elements
(div, p, section, list items, and similar) each get
their own line and indent depth; inline elements (b, a,
span, em) flow together with the surrounding text the way you'd
write it by hand. Minify does the opposite — strips comments and collapses whitespace down
to the smallest reasonable output.
Nothing you paste is ever executed as a live page or sent anywhere — it's treated purely as text to reformat, entirely inside your browser tab.
How to use it
- Paste your HTML, or drop an
.htmlfile onto the input pane. - Set an indent width if you don't want the default two spaces.
- Press Format to beautify, or Minify to compress.
- Copy the result, or download it as a file.
What gets special treatment
Void elements — img, br, input, hr,
meta, and similar tags with no closing pair — don't add a level of indentation
the way a normal container tag does, since there's no content nested inside them.
Content inside pre, textarea, script, and
style is preserved exactly as written. For pre and
textarea, whitespace is part of what actually renders on the page, so changing
it would change the result. script and style contain JavaScript
and CSS respectively — different languages entirely, which this tool leaves untouched rather
than attempting to reformat as HTML.
A note on validation
This reformats structure; it doesn't validate markup. If you're debugging why something doesn't render correctly, a formatter can make the structure easier to read at a glance, but an actual HTML validator is the right tool for confirming every tag is properly matched and every attribute is well-formed.
Questions
Is this HTML formatter free?
Yes, completely, with no signup and no limit on how much you format.
Is my HTML uploaded anywhere?
No. Formatting and minifying both happen in your browser — nothing you paste is sent to a server. You can confirm this yourself: open your browser's Network tab and use the tool, and no requests will appear.
Does it run or render the HTML I paste in?
No, and this matters if you're pasting HTML you don't fully trust. This tool only treats your input as text to reformat — it never executes it as a live page, so a stray <script> tag in something you paste never runs.
What happens to content inside <script>, <style>, <pre>, and <textarea>?
It's preserved exactly as written, without being reformatted or re-indented internally. Whitespace inside <pre> and <textarea> is part of what gets rendered on the page, so changing it would change the output; <script> and <style> contain a different language entirely (JavaScript, CSS), which this tool doesn't attempt to reformat as if it were HTML.
Why do some tags stay on the same line as the surrounding text?
Inline elements — <b>, <a>, <span>, <em>, and similar — flow together with their surrounding text on one line, the way you'd naturally write "some bold text" by hand. Block elements like <div>, <p>, and <section> each get their own line and indent level. Exploding every single tag onto its own line regardless of context is technically valid but reads far worse for anything with inline formatting in running text.
Does this validate my HTML?
No — it reformats structure, it doesn't check that your markup is valid or that every tag is properly closed. If a tag is missing its closing pair, the tool does its best with a reasonable interpretation, but that's a different job than validation.
Related tools
Code & data
CSS Formatter
Beautify or minify CSS in one click.
Code & data
JSON Formatter
Beautify, minify and validate JSON with precise error locations.
Code & data
Markdown Preview
Live side-by-side Markdown editor with HTML export.
Business & documents
Terms of Service Generator
A real starting draft, built from a few questions about your site.