HTML Formatter

Indent nested elements cleanly while preformatted and script content stays verbatim.

Your HTML

Elements: —
Content inside pre, textarea, script and style elements is preserved exactly as written.

How to use the HTML Formatter

  1. Paste the markup you want to re-indent.
  2. Choose a wrap width and tick the option to wrap long attribute lists.
  3. Click Format and copy the tidied HTML.

Features

Advertisement

Frequently Asked Questions

Common questions about the free online html formatter.

It adds indentation so nested elements are easy to follow, and collapses runs of whitespace between tags into a single space.
Whitespace and line breaks can be significant inside pre, textarea, script and style, so those block contents are copied exactly.
Tags such as br, img, input, meta and link that never wrap content. They are written on a single line with no closing tag.
When enabled, a tag whose attribute list is longer than the chosen width is split so each attribute sits on its own indented line.
No. It only reformats whitespace. Broken nesting or invalid attributes are left for you to correct in the source.
Yes. Partial markup and template fragments are formatted the same way, and unclosed tags are still indented sensibly.
No. Formatting runs entirely in your browser, so your markup stays on your device.
Yes, the HTML formatter is completely free and unlimited, with no account required.

Last updated: October 10, 2026