Source tools · Runs in your browser

HTML Formatter

Make HTML attributes easier to read while keeping content spacing intact. For minified page structure, turn on block indentation after reviewing the whitespace warning. Your source is never rendered or executed.

Formatting options

Values, quotes, order and case stay intact.

Off by default. Adds or replaces whitespace between eligible block elements. Inline runs and mixed content stay together.

Default: every content text segment stays unchanged. Attribute wrapping can add lines inside start tags. Block indentation changes text nodes and may affect custom CSS, scripts or templates that depend on whitespace. Review output before replacing a source file.

Limit: 200,000 UTF-16 units and 256 KiB UTF-8. Explicit closing tags required, except HTML void elements. Ctrl/Cmd+Enter formats.

0 units · 0 bytes · 0 lines

Source text only. Download saves a UTF-8 text file named formatted.html.txt.

No result yet

.html, .htm or .txt, up to 256 KiB. Opening a file replaces the input. It is not uploaded.

Ready. Paste HTML or load the sample.

How to format HTML

  1. Paste source or open a local UTF-8 file. Use a complete fragment with explicit matching end tags.
  2. Choose indentation and attribute layout. The default preserves content spacing. Enable block indentation to lay out eligible nested block elements.
  3. Select Format HTML, read the result summary, then copy or download the output.

One-per-line wrapping applies to tags with at least two attributes. Tags with fewer attributes retain their original spelling. Compact mode changes only spacing between complete attributes, never inside a quoted value or around its equals sign.

If the result is unchanged, the source may already match the settings or contain only spacing-sensitive content. This is expected, especially when block indentation is off.

What stays intact

Text, inline spacing, entity spellings, comments, attribute values and quote styles are retained by the default mode. Script, style, textarea and title bodies remain untouched. Entire pre regions and regions with inline style or contenteditable attributes are protected.

Block indentation applies only to recognized containers whose direct content consists of block elements, comments and optional whitespace. Mixed text, inline siblings, unknown/custom element boundaries and empty interiors are kept. Existing comment contents and raw code are never reformatted.

Default mode preserves content text as received from the textarea. Browsers can normalize pasted or file-loaded line endings to LF. Downloads are UTF-8 text, so this is not a byte-for-byte file preservation tool.

Supported source and limitations

This is a bounded source formatter with syntax checks, not a browser parser, HTML validator, sanitizer or minifier. It does not repair markup, check accessibility or validate CSS and JavaScript. A successful result does not mean the source is valid or safe to run.

Omitted end tags, non-void self-closing tags, duplicate attributes, malformed comments, legacy doctypes, SVG/MathML, HTML template/noscript elements and recognized framework or server-template syntax are rejected. Braces outside protected code are treated as possible template syntax. Use the formatter for the original language when working with JSX, Vue, PHP, Blade, Jinja or similar templates.

Limits are 200,000 UTF-16 units, 256 KiB of UTF-8 input, 10,000 lexical tokens, 100 nested elements and 1 MiB of output. Unsupported input produces no partial output. All source remains available for correction.

Whitespace and privacy

Whitespace between tags can create text nodes. CSS such as white-space: pre-wrap can make it visible even inside an ordinary div. Block indentation therefore requires checking the actual page and any code that depends on text nodes.

The tool processes entered source and local files in memory. It does not upload, render, execute or store them, and it makes no formatting network requests. The surrounding site may use its normal page analytics; the formatter sends no source content to analytics.

Technical references: WHATWG HTML syntax, HTML parsing rules and CSS whitespace processing.