HTML Formatter
This tool formats HTML. Each block tag goes on its own line, nested tags are indented, and short text with inline tags stays on one line.
- Free, no sign-up
- Nothing is sent to a server
- Worldwide
How to use HTML Formatter online
- Paste the HTML. Minified or messy.
- Choose the indent. 2 or 4 spaces.
- Read the result. The formatted HTML appears at once.
- Copy it. Copy or save the result.
Why use this free HTML Formatter
- Nested tags indented
- Inline tags kept in the line
- Short text beside its tag
- Pre and script untouched
- Comments kept
- Share by link
Readable markup
HTML copied from a page source, from a tool or from a minifier is often one long line. The formatter breaks it into lines and indents each level of nesting, so you can see how the elements fit together. This helps when you debug a layout, check a template or learn from a page.
How it formats
Block elements such as div, ul and li go on lines of their own, indented under their parent. Inline elements such as b, a and span stay inside the line of text they belong to. A short piece of text stays on the line of its tag, so a heading reads as one line. Void elements such as img and br have no closing tag.
A worked example
The one-line page with a heading, a paragraph with bold text, a list and an image becomes 9 lines:\n
Content that is left alone
The content of pre, textarea, script and style is not changed, because spacing can matter in it. Comments are kept. Attribute text is kept as written, with runs of spaces inside a tag tidied. The tool does not fix errors, so unclosed tags in your input give odd indentation.
Related tools
The HTML minifier does the reverse. The indent can be 2 or 4 spaces. Short text stays on the line of its tag when the line is under 80 characters. For a plain text version of a page, use the HTML to text tool, and to see only the structure of a list, the HTML to Markdown tool.
Using the tool
There is no button to wait for: the HTML Formatter result follows every change. Use result as input to pass the answer to the next step.
HTML Formatter: frequently asked questions
Does formatting change how the page looks?
Does it fix broken HTML?
Is the text inside pre touched?
Can I use 4 spaces?
Do HTML comments survive formatting?
Does the HTML Formatter keep a copy of my text?
Can I save what the HTML Formatter gives me?
Related searches for HTML Formatter
- HTML Formatter online
- free HTML Formatter
- HTML Formatter online free
- HTML Formatter for mobile
- HTML Formatter without sign up
- HTML Formatter – Text & Writing Tools
HTML Formatter is a free online tool on MAITBOX, in the Text & Writing Tools group. It runs in your browser, so what you type is not sent to a server. It works on Android and iPhone, and on Windows, Mac and Linux, with no download and no account.