ToolLineup

HTML Formatter & Beautifier

This HTML formatter re-indents markup and wraps long lines using a real HTML parser rather than pattern matching, which is what lets it handle void elements, attribute values containing angle brackets, and the difference between inline and block elements correctly. Whitespace inside pre and textarea elements is rendered by the browser, so it is preserved exactly as written. Indent size and wrap width are both adjustable, and the whole thing runs in your browser with the parser loaded only when you open the page.

How it works

Re-indents markup and wraps long lines, using a real HTML parser rather than pattern matching — so void elements, attribute values containing angle brackets, and inline versus block elements are all handled correctly.

Whitespace inside <pre> and <textarea> is rendered by the browser, so it is left exactly as written.

Everything runs in your browser — nothing you paste is sent to a server.

HTML input
Paste HTML here…
Formatted HTML

How to format HTML online

  1. Paste your markup into the input on the left.
  2. Pick an indent size and a wrap width.
  3. Copy or download the formatted result.

Why it parses before it prints

The markup is read into a syntax tree and printed back out from that tree, rather than nudged around with pattern matching. That is what makes the result predictable: the formatter knows what is a string, what is a comment and what is structure, so it cannot accidentally reformat something inside a literal. A real HTML parser also handles void elements, attribute values containing angle brackets, and the difference between inline and block elements correctly.

What is left alone

Whitespace inside <pre> and <textarea> is rendered by the browser, so reformatting it would change what the page looks like. Both are preserved exactly as written.

Common use cases

  • Reading minified markup pulled from view-source or a build output.
  • Tidying a hand-edited email template before sending it for review.
  • Making generated HTML legible for a bug report.

Frequently asked questions

How do I format HTML online?

Paste your markup into the left panel and the indented result appears on the right. Set the indent size and wrap width to match your project, then copy or download.

Does it handle inline elements correctly?

Yes. Because a real HTML parser reads the document first, the formatter knows that adding a line break beside an inline element such as a span or an anchor can change the rendered spacing, and lays it out accordingly.

What happens to content inside pre and textarea?

It is preserved byte for byte. Whitespace in both is rendered by the browser, so reformatting it would change what the page looks like.

Can it format a full page or only a fragment?

Both. A complete document with a doctype and a bare fragment are equally acceptable.

Is my code uploaded anywhere?

No. Everything runs entirely in your browser, so nothing you paste is transmitted or stored on a server.

Related tools