XML Formatter

Format and beautify XML

About XML Formatter

XML Formatter re-indents XML using line-based text processing, not a real XML parser, entirely in your browser — nothing is uploaded to a server. It correctly handles the XML declaration and self-closing tags without breaking indentation, and it's scanner-based rather than a plain-text regex: <![CDATA[...]]> sections, <!--...--> comments, and quoted attribute values are recognized as opaque and copied through untouched, so a '><' sequence inside any of them is never mistaken for a real tag boundary. It still doesn't validate whether the XML is well-formed, since it's a text-based indenter, not a true parser.

How to use XML Formatter

  1. 1Paste your XML into the input box.
  2. 2Click 'Format' to re-indent it based on nesting depth.
  3. 3Review the output for proper structure.
  4. 4Click 'Copy' to copy the formatted XML.

Frequently Asked Questions

Is XML Formatter free to use?

Yes, completely free with no registration required.

Does it validate whether my XML is well-formed?

No — it's a text-based indenter, not a real XML parser, so it won't catch structural errors like unclosed or mismatched tags.

Does it handle the XML declaration (<?xml version="1.0"?>) correctly?

Yes — the declaration line is left alone and doesn't affect the indentation of the elements that follow it.

Is my XML uploaded to a server?

No, formatting happens entirely in your browser.

Tips & Tricks

  • For strict validation of whether your XML is well-formed, use a dedicated XML validator, not this formatter.
  • CDATA sections, XML comments, and quoted attribute values are scanned as protected content, so a '><' sequence inside any of them won't get split across lines.
  • Indentation uses a fixed 2-space step per nesting level and isn't configurable.
  • Copy the result right after formatting, since there's no download button or saved history.