HTML Formatter

Format HTML markup into readable indentation using Prettier.

Your input is processed in this browser and is not uploaded.

HTML Formatter

Reformat HTML so nesting is easier to follow. This page uses Prettier’s HTML parser and displays the result as source text.

How to use it

  1. Paste HTML markup into Input text.
  2. Select Run tool to load the formatter and process the source.
  3. Inspect the output, then copy or download it for review in your editor.

Worked example

<main><h1>Hello</h1><p>Welcome</p></main>

formats as:

<main>
  <h1>Hello</h1>
  <p>Welcome</p>
</main>

Limits and troubleshooting

Formatting does not execute scripts, sanitize HTML or audit accessibility. Print width 100 is a formatting preference, not a hard maximum line length. Template dialects or malformed markup may be rejected. Test whitespace-sensitive content in its destination. Limit: 200,000 input characters.

Frequently asked questions

Can formatting make HTML safe to publish?

No. Use a sanitizer designed for the destination and its trust boundary.

Why did the line breaks change?

Prettier applies its HTML layout rules. Keep the original and inspect it with Text Compare when whitespace can affect inline content.

Reference

Prettier's formatting options explain print width and HTML whitespace sensitivity.