HTML Formatter
Re-indent minified or messy HTML so the document structure becomes visible again.
Your data stays on your device
Input — HTML
- characters
- 0
- lines
- 0
- size
- 0 B
Output — Formatted HTML
- characters
- 0
- lines
- 0
- size
- 0 B
Options
About this tool
Markup that has been minified, generated by a template engine, or edited by several people with different editor settings becomes hard to read. Consistent indentation is the fastest way to see nesting and spot an unclosed element.
The formatter understands which elements are inline and should not be broken onto their own lines, and which are block-level and should. It also formats embedded style and script blocks rather than leaving them as one long line.
How to use this tool
- Paste HTML or upload an .html file.
- Set the indent width and the preferred maximum line length.
- Press Format.
- Copy the result or download it.
Key features
- Configurable indent width and wrap column
- Inline elements kept inline, block elements broken onto their own lines
- Embedded <style> and <script> content formatted
- Attribute wrapping options for elements with many attributes
- Comments and conditional comments preserved
- Void elements handled without spurious closing tags
Example
Input — HTML
<ul><li>One</li><li>Two</li></ul>Output — HTML
<ul>
<li>One</li>
<li>Two</li>
</ul>Good to know
- Formatting is not validation. Malformed markup is re-indented as best it can be, not corrected.
- Template syntax such as Handlebars or Jinja may be reformatted in ways that break it; review the output.
- Whitespace is significant inside <pre> and <textarea>, so those are left untouched.
Frequently asked questions
Will formatting change how my page renders?
In most cases no, but whitespace between inline elements is meaningful in HTML. The formatter is conservative, and <pre> content is never touched.
Does it validate my markup?
No. Use a validator for correctness. This tool only changes presentation.
Is embedded CSS and JavaScript formatted?
Yes, style and script blocks are formatted with the same engines used by the dedicated CSS and JavaScript formatter pages.
Can I format a template file?
You can try, but template delimiters are not understood as syntax and may end up in the wrong place. Check the diff before saving.
Your data stays on your device
Your data is processed locally in your browser and is not uploaded to our server. This page keeps working after you go offline, because there is nothing to send.