HTML Beautifier

Reformat messy or minified HTML into clean, indented markup.

Minified HTML is one continuous line thousands of characters long. Beautifying it restores the indentation and line breaks, which is the difference between guessing at the structure and actually seeing it.

Formatting your markup

  1. Paste the HTML you want to tidy.
  2. Choose an indentation style — two spaces is the common default.
  3. Format it.
  4. Read through the structure, which is now visible.
  5. Copy the result into your editor.

It finds unclosed tags for you

This is the underrated benefit. When a beautifier indents your markup, a missing closing tag shows up immediately as a block that never comes back to the left margin. Everything below it drifts further and further right.

That visual cue catches structural errors far faster than reading the source line by line, and unclosed tags are the cause of a surprising share of layout bugs that seem to make no sense.

When you will reach for this

  • Reading the source of a page you did not write.
  • Debugging output from a template engine that produced a wall of markup.
  • Cleaning up HTML that came out of a WYSIWYG editor.
  • Reviewing an email template before sending it.
  • Making a diff readable when the file was committed minified.

Keep formatted source, ship minified output

The two tools are opposite ends of the same workflow rather than competitors. Write and commit readable, indented HTML that a human can maintain, and let a build step minify it on the way to production. Never edit the minified version, and never commit it as your source of truth.

HTML formatting questions

Does beautifying HTML change how the page renders?

It should not, since only whitespace is adjusted. The one exception is whitespace between inline elements, which can be visually significant, so check the rendered result after reformatting.

How many spaces should I indent?

Two spaces is the most common convention in web development and keeps deeply nested markup from running off the screen. Four is also fine. Consistency across your project matters more than the number.

Can this fix broken HTML?

It will make the breakage visible — an unclosed tag becomes obvious once the markup is indented — but it does not repair the structure for you. Use it to diagnose, then fix the source.

Should I commit formatted or minified HTML?

Always commit the formatted version. Minification belongs in a build step, so your repository stays readable and diffs stay meaningful.

Is my code sent to a server?

Yes. Your markup is sent to the server for formatting, but it is not stored once the result is returned.

Cookie
We care about your data and would love to use cookies to improve your experience.