Developer & text tools

HTML formatter and beautifier.

Paste messy or minified HTML and get clean, indented code you can read and edit. Inline text stays together on one line, and the contents of pre, textarea, script and style tags are left as they were. Your code stays in your browser.

  • Free, no sign-up
  • Runs in your browser. Nothing you enter is sent to us.

Clean HTML

How to use the HTML Formatter & Beautifier

  1. Paste your HTML into the box.
  2. Choose the indent you prefer: 2 spaces, 4 spaces or tabs.
  3. Copy the clean code, or download it as an .html file.

What the formatter changes, and what it leaves alone

It adds line breaks and indents around block elements such as div, section and p, and it collapses extra spaces in ordinary text. Inline elements such as a, span and strong stay within their line, because a line break there could add a visible space to your page. The contents of pre, textarea, script and style tags are never reflowed.

It tidies layout only. It doesn't fix broken HTML or close tags you forgot, so if the indents look wrong towards the end, look for a tag that was never closed.

When to format and when to minify

Format code when people need to read or edit it. Minify it when browsers need to download it. Most sites keep readable code while working and send minified code to visitors. Our code minifier does the second job. To turn text written in Markdown into HTML, use the Markdown editor.

Questions

About the HTML Formatter & Beautifier.

Will formatting change how my page looks?

It shouldn't in normal use, because line breaks are only added around block elements. If your CSS relies on exact whitespace between elements, check the result.

Does it fix errors in my HTML?

No. It only changes the layout of your code. It won't close missing tags or correct invalid markup.

Is my code uploaded?

No. The formatting happens in your browser.

Are scripts in my HTML run?

No. Your code is only treated as text, so nothing in it runs.

Can it format PHP or template files?

It is built for HTML. Files with PHP or template tags mixed in may not indent well, so check them carefully.

Want this done for you?

Free tools show you what to fix. We fix it, measure it, and keep it working while you run the business.