⌘

HTML Beautifier

Format html content for easier reading.

0Words
0Characters
0Sentences
0mReading time
Choose a file or fill the fields, then click Run tool.

About HTML Beautifier

View-source output, email templates and markup copied from page builders are often crammed onto a few long lines. Indenting the tags makes it easier to see which div closes where, find a stray wrapper, or clean up a template before editing. It is a quick readability pass for small to medium HTML snippets.

How it works

The beautifier puts a line break between every pair of adjacent tags, wherever one tag ends and the next begins, with only whitespace between them. Each opening tag on its own line adds two spaces of indent, and each closing tag removes one level. Comments, the doctype and self-closing tags do not add depth. Neither do br, hr, img, input, meta and link. Other void tags such as source or area, and one-letter tags such as p, a and b, are not handled specially, so indentation can drift after them. Script and style contents are not reformatted. The output can be saved as pretty.html.

How to use HTML Beautifier

  1. Enter the text or data in the format shown in the text box above (Paste HTML).
  2. Select “Run tool” and check the result before copying or downloading it.

Worked example

Input: <ul><li>One</li><li>Two</li></ul>. Output, four lines: <ul> at the margin, <li>One</li> indented two spaces, <li>Two</li> indented two spaces, and </ul> back at the margin. List items that contain only text stay on one line with their tags.

Tips for a better result

  • Expect indentation to drift after a lone <p> or <a> on its own line. Those tags do not increase depth, but their closing tags reduce it.
  • Inline text next to tags, such as Hello <b>there</b>, is left on one line, so paragraphs stay readable.
  • Format embedded CSS or JavaScript separately with the CSS or JavaScript beautifier, because script and style contents are not touched.

Frequently asked questions

Does it fix broken HTML?

No. It does not parse or repair markup. Unclosed or mismatched tags are reformatted as-is, and the indentation may look wrong as a result, which can actually help you spot the problem.

Will beautifying change how my page renders?

Usually not, but it adds line breaks and spaces between tags that had none. Between inline elements, such as two adjacent images or links, that new whitespace can create a small visible gap.

Can I choose tabs instead of spaces?

No. Each nesting level adds two spaces; the width cannot be changed. Use your editor's indentation setting to convert the output if your project uses tabs.

What to check

A formatted or parsed result is not proof that code is secure, correct or production-ready. Never paste production secrets.

Read the Privacy Policy for information about local processing, connected services and advertising.