HTML Formatter

Pretty-print messy or minified HTML with clean, consistent indentation. Void elements, comments, and pre/script/style are handled correctly. Runs in your browser; nothing is uploaded.

Formatted HTML

About this tool

HTML Formatter pretty-prints (beautifies) HTML with clean, consistent indentation — one element per line, with nested children indented. Paste minified or messy markup and get a readable, diff-friendly version back.

It's a forgiving formatter built for real-world HTML:

Set the indent to your preferred number of spaces per level (0–8, default 2).

Everything runs locally in your browser via WebAssembly — your HTML is never uploaded.

Handy for

FAQ

Will formatting break my <pre>, <textarea>, or inline scripts?

No. The contents of <pre>, <textarea>, <script>, and <style> are kept verbatim — their inner whitespace and line breaks pass through untouched, and only the surrounding tags are indented. So preformatted text, embedded JavaScript, and CSS come out exactly as they went in.

Can I use tabs, or change how deep the indentation is?

The indent setting takes a number of spaces per level, from 0 to 8 (default 2); values above 8 are clamped. Tab indentation isn't supported — if your project uses tabs, format with spaces and convert afterwards.

Does it validate or repair broken HTML?

No — it's a formatter, not a validator. It's deliberately forgiving: void elements like <br> and <img> don't add indent levels, self-closing tags, comments and the doctype are recognized, and a > inside a quoted attribute such as title="x > y" won't confuse it. But it won't report unclosed tags or rewrite invalid markup; what you paste is what gets re-indented.

Can it minify HTML instead of beautifying it?

Not really. Setting the indent to 0 removes the leading spaces but still puts each element on its own line — the output is readable, not compact. For shipping-size reduction, use a dedicated HTML minifier after formatting.

Developer & Automation Access

Run it from the terminal

Same engine as this page, headless — via the gizza CLI:

gizza tool html-formatter "<div><p>Paste your HTML here</p></div>"

New to the CLI? Get gizza →

Open it by URL

Pre-fill and auto-run this tool with query parameters — the names match the API/CLI:

https://gizza.ai/tools/html-formatter/?html=%3Cdiv%3E%3Cp%3EPaste%20your%20HTML%20here%3C%2Fp%3E%3C%2Fdiv%3E&indent=2

Machine-readable descriptor: tool.json — title + parameters JSON Schema for agents.