HTML Formatter & Minifier
FormatEverything runs locally in your browser — nothing is uploaded
Expand a minified HTML document into an indented structure. Unlike formatters that break at every tag, this one looks at the text: once an element contains actual text, its whole subtree stays inline, because a newline in HTML is a real space. Moving the <b> in <p>a<b>x</b> onto its own line turns the rendered result from "ax" into "a x". For the same reason no space is invented where the source had none.
Features
- The output is syntax-highlighted, with keywords, strings and comments colour-coded
- Indent by tag level with 2-space, 4-space or tab indentation
- Knows the void elements (br, img, meta, input, link and friends), so following content is not indented an extra level
- Keeps text and inline tags on one line and only inserts a space where the source had one
- Preserves the content of script, style, pre and textarea, with the closing tag written flush against it
- Comments and the DOCTYPE get their own lines, and whitespace runs inside tags collapse to a single space
- Whitespace inside attribute values is preserved, and a > inside a value does not end the tag
- Minify mode removes the whitespace between tags and the comments
- No syntax validation: unclosed tags are indented as best they can rather than rejected
How to use
- Paste your HTML into the input box
- Pick the mode and indentation
- Press Ctrl/⌘ + Enter or click Run
- Click Copy to take the result
FAQ
- Why did minifying remove some spaces from my page?
- Minify deletes the whitespace between tags. That is usually harmless, but the space between inline elements is a real gap when rendered, so <span>a</span> <span>b</span> becomes "ab". Use format mode when that gap matters.
- Why is the text not broken across lines?
- Breaking it would insert real spaces and change what the browser renders. Line breaks are only added at structural positions; text stays where it was.
- Is the content of script and pre reformatted?
- No. Those elements are carried through verbatim, with the closing tag written right after the content, so nothing inside their code or layout is disturbed for the sake of tidiness.
- Is my HTML uploaded anywhere?
- No. Everything runs in your browser memory, the page makes no network requests, and it works offline.
Related tools
XML Formatter
FormatFormat XML online by tag level, with comments, CDATA and DOCTYPE on their own lines and attribute values left untouched. Runs locally in your browser.
HTML Entities
EncodingTurn < > & and quotes into HTML entities and decode them back in a single pass, so &lt; becomes <, not an angle bracket. Runs in your browser.
Markdown Preview
TextWrite Markdown on the left, see it rendered on the right — heading anchors, a table of contents, highlighted code blocks. Pasted HTML stays text.
JSON Formatter
FormatFormat, validate and minify JSON in a collapsible tree with syntax highlighting and line numbers. Search, edit, delete or convert to Python dicts.
JSON to Code
FormatTurn JSON into TypeScript interfaces, Go structs, Java classes or Rust structs, with missing keys marked optional. Runs locally in your browser.
SQL Formatter
FormatFormat SQL online: one clause per line, consistent keyword case, subqueries indented deeper. Minify strips comments and extra whitespace, all locally.