← All tools/Minifiers/Code/HTML Formatter

HTML Formatter

Turn squashed HTML into clean, indented code you can actually read — in your browser, with nothing uploaded.

Runs in your browser — nothing is uploaded. Only whitespace changes; your tags, text and attribute values stay exactly as they are.

Formatted HTML

—

Original
Formatted

How it works

Split the markup at tag boundaries, then re-indent one level per nesting depth.
An opening tag, its text and its closing tag stay on one line when they fit together.
Closing tags step one level back out. Only whitespace changes — tags, text
and attribute values are never touched.

Worked example: paste <div><p>Hello</p></div> with a 2-space indent and you get three lines — <div>, then two spaces and <p>Hello</p>, then </div>. The text “Hello” stays on the same line as its paragraph tags, because an element that only holds text does not need splitting.

Frequently asked questions

Does formatting change how my page looks?

No. Formatting only adds line breaks and spaces between tags, which browsers ignore in HTML. Your tags, text and attribute values stay exactly as they were.

What indent should I pick?

Two spaces is the most common choice and the one this tool uses by default. Four spaces reads better in deeply nested pages, and tabs suit editors set up for tabs.

Can I format a whole HTML document?

Yes. Paste the full document, including the doctype, head and body. The formatter indents every level and leaves the doctype on its own line.

Does it work with attributes and inline elements?

Yes. Attribute values are never touched, and an element that only holds text, such as <p>Hello</p>, stays on one line instead of being split across three.

Is my code uploaded anywhere?

No. Everything runs in your browser on this page. Your HTML never leaves your device.

More tools

Tell us what you think

Loving this tool, or stuck on something? Tell us — it takes a minute.

We’ll only use your name and email to reply if needed. The tool and page are filled in for you.