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.
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
- Open the formatter: Load the page and find the XML textarea and Format button.
- Paste your document: Replace the sample with the XML you want to indent.
- Click Format: Press Format to validate structure and apply two-space indentation.
- Copy indented output: Select the formatted block from the result area and paste it elsewhere.
Common use cases
- Pretty-print SOAP or config XML copied from a server response before emailing a teammate.
- Make nested RSS or sitemap snippets readable during content debugging.
- Show beginners how element hierarchy looks when each tag occupies its own indented line.
Tips
- Processing instructions and DOCTYPE lines are not treated as nesting openers.
- Self-closing tags like <item/> keep the current indent without adding depth.
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.