HTML Formatter & Beautifier
Format minified or inline HTML with proper indentation and line breaks.
How to use this tool
- 1
Paste your minified or single-line HTML into the input box.
- 2
Read the indented result that appears below as you type — there is no button to press.
- 3
Select and copy the formatted output from the result panel.
- 4
Spot-check anything with <pre>, <textarea>, comments, or inline scripts, since those are not handled perfectly.
What does this HTML formatter actually do?
It re-indents HTML so nested elements become readable: each tag goes on its own line, and every level of nesting adds two spaces of indentation. Void elements that never have children — img, br, hr, input, meta, link and the rest — stay inline and do not increase the indent. Internally it is a regex tokenizer, not a real HTML parser. It splits the markup on anything between < and >, collapses whitespace that sits between tags, and trims text nodes. That makes it fast and dependency-free, but it has real limits you should know. Because it removes whitespace between and inside elements, the output is not guaranteed to render identically to the input: significant whitespace between inline elements (a space between two <span> tags, for example) is lost, and the contents of <pre> and <textarea>, where whitespace is meaningful, get collapsed. The tokenizer also does not specially handle comments, <script>/<style> bodies, or attributes whose values contain a > character. For everyday minified markup it works well; for those edge cases, reach for a full parser-based formatter such as Prettier or js-beautify.
Common use cases
Expanding a minified production HTML page so you can read its structure during debugging.
Tidying a snippet copied from a browser's DevTools Elements panel before pasting it into documentation.
Re-indenting a fragment of email or marketing HTML that arrived as one long line.
Inspecting the nesting and tag hierarchy of unfamiliar markup at a glance.
Cleaning up generated or template-output HTML before committing it to a repository.
Teaching or reviewing HTML structure where consistent two-space indentation makes nesting obvious.
Frequently asked questions
Does the formatted output render exactly like my original HTML?▼
Will it preserve whitespace inside <pre> or <textarea>?▼
How does it handle HTML comments and <script> or <style> blocks?▼
Is this a real HTML parser?▼
How much does it indent, and can I change it?▼
Is my HTML uploaded anywhere?▼
Related tools
JWT Decoder
Decode JSON Web Tokens (JWT) instantly — inspect the header, payload, and signature claims. Runs entirely in your browser; tokens never leave your device. Safe for production secrets.
JSON Formatter & Validator
Format, validate, and minify JSON instantly. Catches syntax errors with line numbers, pretty-prints with adjustable indent, supports large payloads. Runs in your browser — no upload.
XML Formatter & Beautifier
Format and beautify XML documents — proper indentation, line breaks, namespace handling. Useful for SOAP responses, sitemaps, RSS feeds, and Android resource files.
Base64 Encoder & Decoder
Encode and decode Base64 strings.
URL Encoder & Decoder
Encode/decode URL-safe strings.
HTML Entity Encoder & Decoder
Convert special characters to/from HTML entities.