Menu
PDF Tools
Image Tools
Converters & Utilities
Seller & Print Tools
Accounting & Business
Calculators
Text & Writing Tools
Developer & Web Tools
Creator & Social Tools
Browser Utilities & Games
Document & Design Makers
Text & Developer Tools
Exam & Form Tools

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.

How to use HTML Formatter online

  1. Paste the HTML. Minified or messy.
  2. Choose the indent. 2 or 4 spaces.
  3. Read the result. The formatted HTML appears at once.
  4. 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?
It should not, but the added white space can show as a gap between inline elements.
Does it fix broken HTML?
No. It only changes layout.
Is the text inside pre touched?
No, it is left exactly as typed.
Can I use 4 spaces?
Yes, choose the indent.
Do HTML comments survive formatting?
They stay in place, indented with the tags around them.
Does the HTML Formatter keep a copy of my text?
The HTML Formatter works locally, and clearing the site data removes anything the editor saved.
Can I save what the HTML Formatter gives me?
Press Use result as input and the HTML Formatter answer becomes the new input.

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.

More tools in Text & Writing Tools →

Search tools