๐Ÿงฝ HTML Code Formatter

Indents HTML code to match its tag structure.

How to use

  1. Enter your HTML code.
  2. Click "Format".
  3. You'll see the code indented to match its tag structure.

๐ŸŽฏ Use Cases

Example

Input
<nav><a href="/">Home</a></nav>
Output
<nav>
  <a href="/">
    Home
  </a>
</nav>

A single-line HTML snippet is re-indented with 2 spaces to reflect its tag nesting, while the text and the href="/" attribute are preserved unchanged.

FAQ

Is this based on a full parser?
No. It's a lightweight formatter that recognizes tag structure to indent code, and preserves the contents of script, style, and pre tags exactly as-is.
Can it still format invalid HTML?
It does its best to format the code even with syntax issues like unclosed tags, but for full validation, use the HTML5 Validator alongside it.
Is the code I enter sent to a server?
No. It's processed entirely in your browser.

More Coding Tools

๐Ÿ“˜
JSON Formatter
Prettify, validate & minify JSON
๐Ÿ—“๏ธ
Timestamp Converter
Convert Unix timestamp โ†” date
๐Ÿงฉ
JSON String Encoder
Convert text โ†” JSON string literal
โœจ
JS/CSS Formatter
Indent & tidy JS/CSS code
โœ‚๏ธ
JS/CSS Minifier
Strip comments & whitespace
๐Ÿงน
XML Formatter
Indent XML by tag structure
๐Ÿ—ƒ๏ธ
SQL Formatter
Break SQL into clauses & indent
๐Ÿ”ฃ
HTML Entity Encoder
Convert special chars โ†” HTML entities
๐Ÿ“Š
Excel to HTML Table
Convert spreadsheet data to HTML TABLE
โ›“๏ธ
Link Extractor
Extract href/src links from HTML
๐ŸŽจ
Color Picker
Get HEX, RGB & HSL color codes
๐Ÿ˜
PHP Syntax Checker
Check bracket/string pairing (practical checker)
๐Ÿ—„๏ธ
MySQL Syntax Checker
Check bracket/quote pairing (practical checker)
๐Ÿ”
HTML5 Validator
Check tag pairing, duplicate id, missing alt
โœ๏ธ
Online HTML Editor
Write & edit HTML visually