HTML Formatter

Turn minified or messy HTML into clean, consistently indented markup. Choose 2 spaces, 4 spaces or tabs, set a wrap length and decide whether to keep blank lines; embedded CSS and JavaScript are formatted as well. Formatting is powered by the widely used js-beautify library and runs entirely in your browser.

How to use the HTML Formatter

  1. Paste your HTML or press Load example.
  2. Pick the indent size and an optional wrap line length.
  3. Choose whether to keep blank lines and end with a newline.
  4. Press Format HTML, then copy or download the result.

Features

Benefits

Frequently asked questions

Will formatting break my page?

Formatting only changes whitespace between tags. Content inside <pre> and <textarea> is left alone, but whitespace-sensitive inline layouts can shift slightly, so review the result.

Does it fix invalid HTML?

No. It re-indents the markup as written. Missing closing tags are not added, so the indentation may look uneven around errors.

What does wrap line length 0 mean?

Zero turns wrapping off, so long lines are kept on one line.

Related tools