HTML Formatter

Format/beautify HTML code. Free, instant.

\\n<').split('\\n').forEach(l=>{l=l.trim();if(!l)return;if(l.match(/^<\\//))p--;r+=' '.repeat(Math.max(0,p))+l+'\\n';if(l.match(/^<[^/!?]/)&&!l.match(/\\/>/)&&!l.match(/<.*<\\//))p++});return r.trim();"}'>

How to Use HTML Formatter

1

Paste HTML.

2

Get formatted output.

3

Copy or download your result.

Frequently Asked Questions

Does it fix errors?

No, it only adds indentation. It does not fix invalid HTML.