HTML formatter
Indent HTML so the structure is readable, or minify it.
Runs in your browser. Your input is not uploaded.
What it does
The formatter puts each block element on its own line and indents children, so the structure of a page or template is readable. Inline elements such as <a> and <strong> stay in their line of text.
The contents of <script>, <style>, <pre> and <textarea> are left exactly as they were, because whitespace there matters.
How to use it
- Paste HTML.
- Choose the indent.
- Copy the formatted markup.
Things to watch for
- This is a lenient formatter, not a validator. Unclosed tags are not reported or fixed.
- Adding new lines between inline-block elements can add visible gaps in some layouts.
Questions
- Will it fix broken HTML?
- No. It formats what is there. Browsers repair broken markup in their own way, so fix it at the source.
- Does it format embedded CSS and JavaScript?
- No. Script and style contents are kept as they are.
- How do I minify HTML instead?
- Use the CSS and HTML minifier.
- Does it run scripts in my HTML?
- No. The HTML is processed as text and never inserted into the page.