Skip to content

Re-indents minified or tangled markup so the nesting is visible — the fastest way to read a page you did not write.

2 spaces
Formatted HTML Code

What is Online HTML Formatter?

HTML Formatter is a free online tool for formatting HTML code with HTML Beautifier to increase readability. HTML is a markup language which defines the skeleton of a webpage. It not only defines structure with div's and other tags but also includes inline CSS or JS and give references to external files. To sum up, all elements of a website are merged in HTML.

When you deal with HTML code, sometimes it may be somehow unformatted, and it can be problematic to read it and add/update features. For increasing your productivity, it is suggested to format your HTML code with some standards.

There are many configurative parameters for HTML beautification, yet online HTML Formatter use default parameters for decreasing complexity. Only indent size is configurable, and it is sufficient for most cases.

There is an image below that shows before and after state for formatting of a HTML code sample. It is obvious that it is easier to read and control the code after formatting. It is especially crucial if the length of your code increases.

HTML Formatting Before vs. After
HTML Formatting Before vs. After

How to use Online HTML Formatter?

You can beautify your HTML code just by using the guide below.

  1. Fill input field with the HTML code you want to format.
  2. You can set indent size if you want to use a value other than 2. Most common indent sizes are 2-space and 4-space indentation, but it is all up to you. You can set any value that makes your comfortable when reading code.
  3. When all are set, click the button "Format". A downloadable file named index.html will be available when you click the button "Download". Or you can copy the formatted HTML into your clipboard.

Frequently asked questions

What does formatting change?

The whitespace, and only the whitespace. Tags, attributes and content stay exactly as they were — the markup is re-indented so the nesting is visible, which is what makes a deeply nested layout readable.

Can I format minified HTML?

Yes, and it is the most common reason to use this. Pasting in a page from view-source gives you back something with a visible structure, which is the fastest way to work out how somebody built a component.

Will formatting change how the page renders?

Almost never, but not quite never. Whitespace between inline elements is significant, so adding line breaks between spans can introduce a space that was not there. Worth checking if your layout is inline-heavy.

Does it fix broken HTML?

No. It indents what you give it; it does not close your unclosed tags or correct nesting. If the structure is wrong, formatting will make that obvious rather than repair it — which is often all you needed.

What about the styles and scripts inside?

Inline CSS and JavaScript come along for the ride. For a real tidy-up of those, the CSS Formatter and JavaScript Formatter go deeper.