Skip to content

Format HTML

Format compact or poorly indented HTML code to make it readable, using Prettier's formatting engine directly in your browser.

Processed on your device. Nothing is sent to any server.

Uses the same formatting engine as Prettier, one of the most widely used code formatters, to give HTML consistent indentation.

Use cases

  • Formatting HTML generated by a tool or exported without indentation.
  • Preparing a readable HTML snippet for documentation.
  • Visually reviewing the structure of complex HTML.

How it works

  1. 1

    Paste your HTML

    Type or paste the HTML code into the input box.

  2. 2

    Format it

    Click Format and copy or download the result.

Technical details

  • It applies Prettier's default options: 2-space indentation and lines up to 80 characters. They can't be changed.
  • Prettier preserves whitespace that affects how text renders, which is why it sometimes breaks tags in unusual ways (for example, with the closing > on the next line).
  • The formatter loads the first time you use it, so the first run takes a little longer.

Frequently asked questions

Does it execute the HTML or just format it?

It only formats it as text; the HTML you enter is never rendered or executed, so it's safe to paste code from an unknown source.

← Developer