Code tool

HTML Formatter

Paste an HTML fragment or document, choose readable indentation or compact output, and clean it up without uploading your markup.

In-browser processingNo account requiredPrivacy details ↗

Up to 200,000 characters. Formatting happens locally in your browser.

A QUICK WALKTHROUGH

How to use this tool

  1. Paste HTML up to 200,000 characters into the editor.
  2. Choose pretty print or compact output and an indentation width.
  3. Format the markup, review the browser validation status, then copy or download the result.

Readable HTML structure

Pretty print places nested elements, comments, and doctype declarations on clear lines using your selected two, four, or six space indentation. Compact output removes formatting whitespace between tags for smaller snippets.

Browser parsing, local output

The page uses the browser HTML parser and serializer. Parsing, formatting, copying, and downloading happen locally in your browser; no HTML is sent to a server. The browser may repair malformed markup according to HTML parsing rules.

GOOD TO KNOW

Common questions

Does this upload my HTML?

No. Your markup stays in the current browser session and is processed locally.

Can I format a complete HTML document?

Yes. Paste a fragment or a complete document including doctype, head, and body elements.

Will invalid HTML produce an error?

HTML is forgiving by design. The browser parses and repairs common markup mistakes, so the result reflects the browser DOM rather than an XML-style validation error.

Does compact mode remove meaningful text?

It removes whitespace between markup tokens while preserving text, comments, attributes, and document content.