XML Formatter

Paste XML into the textarea (the sample is <root><item id="1">hi</item></root>) and click Format. The tool checks for angle brackets, balanced tags, and recognizable element syntax, splits adjacent tags onto new lines, then indents each nesting level by two spaces.

Updated 2026-08-04 · Developer

Click Format.

About this tool

Formatting is structural, not schema-aware. Closing tags reduce indent before printing; opening tags that are not self-closing or declarations increase depth. Empty input returns Enter XML; mismatched brackets or missing tag structure returns Invalid XML.

How to use

  1. Open the formatter: Load the page and find the XML textarea and Format button.
  2. Paste your document: Replace the sample with the XML you want to indent.
  3. Click Format: Press Format to validate structure and apply two-space indentation.
  4. Copy indented output: Select the formatted block from the result area and paste it elsewhere.

Common use cases

Tips

FAQ

Does this validate against an XSD?

No. It only checks basic tag shape and bracket balance before indenting.

What makes XML invalid here?

Missing brackets, unequal < and > counts, or no recognizable open/close tag pair.

How much is each level indented?

Two ASCII spaces per nesting level, applied line by line.

Is my XML uploaded anywhere?

Formatting runs entirely in your browser when you click Format.

Related keywords

Related tools