{{ summaryTitle }}
{{ summaryValue }}

{{ summaryLine }}

Indent {{ resultsReady ? indentLabel : '—' }} Elements {{ resultsReady ? computation.values.element_count : '—' }} Processing Local only

HTML source formatting controls
Paste a document or fragment up to 120,000 characters, or load one local HTML, XHTML, or text file.
{{ sourceMeta }}
{{ fileStatus }}
Choose the style expected by the editor, review, CMS, or email workflow receiving the source.
The neutral default leaves the final token as the last character.
{{ final_newline ? 'Enabled' : 'Disabled' }}

{{ computation.values.formatted_html }}

The chart renderer is unavailable. The same counts remain available in the format audit.

Signal Value Review meaning Copy
{{ row.label }} {{ row.display }} {{ row.detail }}

Readable HTML makes document structure easier to review. Indentation reveals which elements are nested, line breaks separate major blocks, and consistent spacing reduces noise in code review. Formatting is especially useful for minified fragments, generated email markup, copied CMS templates, and documents whose visual rendering hides structural mistakes.

Formatting and validation solve different problems. A formatter can arrange the tokens it recognizes without proving that the document follows every HTML parsing rule. An unmatched closing tag may still be printed neatly, and an opening element left at the end of the source may still need repair. Clean indentation should therefore be treated as a review aid, not a certificate that the markup is correct or accessible.

Block element
A structural element such as a section, heading, list, table, or paragraph that normally earns its own line.
Void element
An element such as <img>, <br>, or <meta> that does not contain child content or need a closing tag.
Literal-content element
An element such as <pre>, <textarea>, <script>, or <style> whose body should not be reflowed as ordinary markup.

Whitespace carries different meanings in different places. Leading indentation outside elements can usually be regenerated, while spaces inside quoted attributes, preformatted text, scripts, and styles may be significant. A cautious source formatter keeps literal bodies intact and normalizes only the surrounding markup and ordinary text.

Inert formatting matters when the source is untrusted. Pasted tags, event handlers, styles, image references, and scripts should remain plain text during review rather than being mounted as a document. This avoids turning a formatting task into an accidental preview or execution path.

Formatting also changes the source representation. It may collapse ordinary text whitespace, move elements onto new lines, and add indentation even when the rendered page looks the same. Preserve a copy of the original when byte-for-byte stability, template delimiters, unusual XML rules, or exact whitespace is important.

How to Use This Tool:

Format a document or fragment as inert source, then use the balance signals to decide what still needs manual review.

  1. Paste up to 120,000 characters into HTML source, or load one local HTML, XHTML, or text file up to 250 KB.
  2. Choose two spaces, four spaces, or tabs under Indentation to match the destination project's convention.
  3. Enable Final newline only when the receiving editor or repository expects a line feed after the last token.
  4. Read the summary before copying the result. If it reports lexical balance signals, inspect Format audit for unmatched closing tags and elements left open; the formatter does not repair them.

Interpreting Results:

Formatted HTML is the rewritten source. Compare sensitive sections such as templates, inline text, <pre> blocks, scripts, and styles before replacing the original. The element and text counts describe recognized source tokens; they do not measure rendering quality, accessibility, or standards conformance.

A Balanced result means the lexical scan found no unmatched closing tokens and no tracked elements left open. It does not account for every recovery rule used by a browser's HTML parser. Validate important production markup separately, and test the rendered document in its real environment.

Technical Details:

HTML source contains declarations, comments, opening and closing tags, ordinary text, and literal bodies. Safe formatting begins by separating those token classes without rendering the document. Quoted attribute values are scanned as protected spans, so a greater-than sign inside a quote does not end the tag early.

Transformation Core

The formatter follows a bounded token-to-layout transformation. Each stage has a narrow purpose, which makes it possible to distinguish layout changes from unresolved structure.

HTML formatting transformation stages
StageTransformationPreserved boundary
Token scanSeparates tags, comments, declarations, text, and literal bodies.Quoted attribute content and complete comment or CDATA spans stay intact.
Nesting passTracks recognized opening and closing element names.Unmatched closings remain visible; missing closings are counted rather than invented.
Whitespace passCollapses ordinary text runs and redundant whitespace between tag parts.Whitespace inside quoted attributes and literal-content bodies is retained.
Layout passPlaces structural elements on indented lines and keeps short inline-only content together.Inline content is kept on one line only when the compact element fits the available width.
Ending passJoins output with line feeds and optionally appends one final line feed.The selected indentation unit is used consistently at each nesting depth.

Short elements containing no block children may stay inline when their compact representation fits within a 96-character layout allowance after indentation. Longer or structurally nested elements break across lines. Ordinary text whitespace is reduced to single spaces before layout, except that an explicit two-space line ending inside source text is not treated as an HTML-specific hard-break rule.

The scan rejects an unclosed comment, CDATA section, tag token, quoted attribute, or literal-content element because a safe boundary cannot be determined. By contrast, a completed closing tag without a matching tracked opener is retained and reported. An opener still on the nesting stack at the end is also reported without an inserted closing tag.

HTML formatter scope and limitations
QuestionWhat the result supportsWhat it does not establish
ReadabilityConsistent indentation, line breaks, and compact tag spacingA preferred style for every project or templating language
BalanceCounts unmatched closing tags and tracked elements left openFull browser parse-tree equivalence or semantic validity
SafetyProcesses the source locally as inert textSanitization of markup for later rendering
ContentPreserves literal bodies and quoted attribute valuesByte-for-byte preservation of ordinary text whitespace

The source is never rendered, executed, or uploaded during formatting. Remote images, fonts, scripts, and styles referenced by the pasted markup are not fetched. This privacy property applies to the formatting step; it does not make the copied markup safe to render elsewhere.

References: