HTML Formatter

How it works
Indent
Valid HTML

Input HTML

No problems found. This is valid HTML.

About HTML Formatter

HTML copied from a page source, an email template or a CMS export is often squashed onto a few long lines. The formatter indents nested elements, wraps long lines and also tidies CSS in style tags and JavaScript in script tags.

While formatting, it checks the markup and warns about unclosed tags, stray closing tags, closing tags on void elements such as br or img, and duplicate attributes.

How to use it

  1. Paste your HTML into the Input panel, or Open an .html file.
  2. Choose an indent of 2, 4 or Tab.
  3. Switch the Output panel to Preview to check that the page still renders as expected.
  4. Copy the formatted HTML or Download it.

Frequently asked questions

Can formatting change how my page looks?

Rarely. Whitespace between inline elements can matter in HTML, so the formatter is careful around it, but it is worth a quick look in Preview.

Does it fix broken HTML?

It reports problems such as unclosed or mismatched tags with their position, so you can fix them. It does not guess what you meant.

Is the Preview safe for HTML I do not trust?

The preview runs in a sandboxed frame with scripts disabled, so the HTML cannot run code on this page.

Related tools