Correct tag handling is the foundation of well-formed HTML, and a formatter that does not understand the difference between block, inline, and void elements will produce output that looks formatted but actually breaks rendering in subtle ways.
Loading HTML Formatter…
Correctly handles block, inline, and void elements
Places each block tag on its own line
Preserves inline elements within text flow
Free with no sign-up required
Drop the HTML Formatter into any page — blog post, product docs, intranet, school portal — with a single line of HTML. Your visitors get the full tool, processed entirely in their browser. No backend, no uploads, no signup.
Embed code
<iframe
src="https://www.fixtools.io/html/html-formatter?embed=1"
width="100%"
height="780"
frameborder="0"
style="border:0;border-radius:16px;max-width:900px;"
title="HTML Formatter by FixTools"
loading="lazy"
allow="clipboard-write"
></iframe>Attribution-friendly: a small "Powered by FixTools" link appears in the embed footer.
HTML tags fall into three categories that determine how a formatter should treat them, and understanding these categories is essential for evaluating any formatting tool. Block-level elements such as div, section, article, p, h1 through h6, ul, ol, and table each occupy their own line and indent their children one level deeper. Inline elements such as span, a, strong, em, code, small, and time stay within the text flow of their parent and do not force new lines because adding line breaks around them would introduce whitespace that browsers may render as small visible gaps. Void elements such as img, br, hr, input, link, and meta have no closing tag and no children, and they are placed on their own lines at the appropriate depth without any closing tag being added. A formatter that does not distinguish between these categories produces incorrect output for real-world HTML.
FixTools applies the HTML5 element content model to determine how each tag is formatted in the output. The formatter knows which elements are block-level and places them on their own lines with correct indentation. Inline elements are kept in the same text run as their siblings to preserve reading flow and avoid introducing whitespace gaps. Void elements are placed on their own lines at the correct depth without a closing tag, matching the HTML5 specification's treatment of self-closing elements. This means the formatted output matches how browsers actually interpret the HTML, making it easier to reason about rendering behaviour from the source code alone.
Custom elements present a special case in HTML5. Any element name that is not recognised as a standard HTML element is treated as a block-level element by default, which is consistent with how browsers handle unknown elements per the HTML5 unknown element handling specification. Web components, framework-specific elements such as router-outlet from Angular or ion-button from Ionic, and any project-defined custom element with a hyphenated name are therefore formatted as block elements with their own lines and child indentation. This works correctly for the vast majority of custom element usage in real-world projects because custom elements are almost always intended to behave as blocks.
A subtle but important point is that the formatter respects the HTML5 content model rather than enforcing rules from earlier HTML versions or from XHTML. This means void elements appear without trailing slashes by default if your input did not include them, and they appear with trailing slashes if your input used the self-closing XHTML style. The formatter preserves your choice rather than imposing one. This matters for projects that prefer one style for consistency reasons and for build pipelines that may transform one style into the other before deployment.
Paste HTML with any tag structure and click Format. The output correctly indents block elements, keeps inline elements in context, and places void elements properly.
Step-by-step guide to format html tags online:
Paste your HTML
Paste any HTML with any tag structure into the input panel of the HTML Formatter. The tool accepts fragments containing only inline elements, complete documents with full doctype declarations, or anything in between, and the parser handles all of these with the same content model rules.
Click Format
Click Format to run the parse and re-serialise step. The tool applies correct formatting rules for block, inline, and void elements based on the HTML5 specification, producing output that matches how browsers actually interpret the same input.
Review tag structure
Scan the formatted output to verify closing tags are in the expected places, nesting depth matches your intent, and void elements appear without closing tags. The indented structure makes structural issues immediately visible in a way that compressed HTML never can.
Copy the formatted HTML
Copy the clean, tag-correct HTML with the clipboard button and use it in your project, pull request, documentation, or test code. The original input remains in place in case you want to re-run with different indentation settings.
Common situations where this approach makes a real difference:
Debugging a CSS selector that stops matching after a CMS update
A navigation component stops responding to its CSS selector after a CMS update. Formatting the new HTML output reveals that the nav element is now wrapped in an additional div injected by the CMS, shifting the selector path by one level and breaking the rule. The fix is a one-character selector adjustment, but identifying the cause required formatting.
Reviewing a vendor-supplied HTML template
A vendor delivers a twenty-eight kilobyte HTML email template with no indentation whatsoever. Formatting reveals three unclosed table rows and two img tags with stray closing tags, all of which are fixed before the template is sent to any subscribers. The structural issues were invisible in the unformatted form and would have caused rendering bugs in older email clients.
Writing Cypress end-to-end tests for a new feature
A developer formats the feature's HTML output before writing tests so the tag hierarchy is unambiguous. The clear structure reduces test authoring time compared to inspecting compressed output in DevTools, and the resulting tests are less brittle because the selectors are based on the actual structural relationships rather than guesses about nesting.
Auditing ARIA attributes in a form component
An accessibility reviewer formats a twelve kilobyte form HTML before review. The indented structure immediately surfaces an aria-describedby pointing to a non-existent element ID, which would have been missed entirely in the minified version because the ID values were not visible alongside their referencing attributes.
Use this when you want to verify and clean up tag structure, ensure all open tags have matching closes, void elements are handled correctly, and nesting is visually clear.
Get better results with these expert suggestions:
Use formatted output to audit ARIA landmark roles
After formatting, the indented structure makes it straightforward to verify that ARIA landmark roles such as role main, role navigation, and role banner are on the correct elements and are not nested inside each other incorrectly. This kind of structural audit is much harder on compressed HTML because the landmark relationships are not visible without trace-counting tag pairs. Formatted output turns an hour-long landmark audit into a fifteen-minute scan that catches the same issues with less fatigue.
Format to catch implicit closing tag assumptions
Some HTML elements such as li, dt, dd, and td have optional closing tags that browsers infer automatically per the HTML5 parsing rules. When formatting, FixTools adds the missing closes where the specification allows implicit closure, which makes your structural intent explicit. Review these additions to confirm they match what you actually wanted, because in rare cases the parser's inferred closure point may not match your mental model of where the element should have ended.
Use tag-level formatting to debug CSS selector issues
When a CSS selector is not matching as expected, format the HTML and trace the element path visually from root to target. Indentation makes the exact parent-child and sibling relationships visible, which is often faster than using browser DevTools for simple selector debugging. This is especially useful when the selector relies on combinators such as direct child or general sibling that depend on precise structural relationships.
Format custom element HTML before writing automated tests
When writing Playwright or Cypress end-to-end tests for pages that use custom elements or web components, format the HTML first so the tag hierarchy is unambiguous. The formatted structure gives you the exact tag path you need to write accurate CSS selectors and ARIA queries in your test code, which prevents the frustrating situation where a test fails because the selector matched the wrong element due to structural confusion in the source HTML.
Check void element usage after formatting
After formatting, scan for any img, input, or hr tags to confirm they have no closing tags. Stray </img> or </br> tags indicate non-standard markup that may cause parsing inconsistencies.
Use the output to verify nesting visually
Formatted output makes it immediately obvious when a closing tag is in the wrong place. If the indentation shifts unexpectedly, a mismatched tag is almost always the cause.
Inline elements within block context is expected
Seeing a span or a inside a p without its own indented line is correct behaviour, not a bug. The formatter keeps inline elements within their text flow intentionally.
More use-case guides for the same tool:
Open the full HTML Formatter — free, no account needed, works on any device.
Open HTML Formatter →Free · No account needed · Works on any device