How to use the XML Formatter & Validator
- Paste your XML into the left box, or click Load sample.
- Choose an indent (2 spaces, 4 spaces or tab), or tick Minify instead to remove the whitespace between tags.
- Read the result on the right. If the XML is broken, the status bar shows the line and column, and the cursor jumps there.
- Click Copy to grab the result.
What the formatter keeps
The XML is parsed by your browser's own XML parser, so the result is exactly what other XML tools will read. Formatting only changes the whitespace between tags:
- The
<?xml version="1.0"?>declaration,<!DOCTYPE>, comments and processing instructions <![CDATA[…]]>sections, unchanged- Namespaces and prefixes such as
soap:Envelopeandxmlns:xsi - Mixed content like
<p>Hello <b>world</b></p>and anything markedxml:space="preserve", which are left as written so no spaces are added or lost
Common XML errors
- Mismatched or unclosed tags: every
<item>needs a matching</item>, or write it as<item/>. - A bare ampersand: write
&instead of&in text and attributes. The HTML escape tool can convert text for you. - Unquoted attributes:
id=1must beid="1". - More than one root element: an XML document must have exactly one top-level element.
- Text before the declaration:
<?xml …?>must be the very first thing in the file, with nothing before it.
Where you'll meet XML
SOAP APIs, RSS and Atom feeds, sitemaps, Android layouts, Maven pom.xml, .NET config files, SVG images, Office documents and many bank and government data exchanges all use XML. Need JSON instead? Most APIs offer both. For SVG files, the SVG optimizer also shrinks them.
Frequently asked questions
Is my XML uploaded anywhere?
No. Parsing and formatting happen in your browser. Your data never reaches a server, so it's safe for config files and API responses.
Does it validate against a schema (XSD or DTD)?
It checks that the XML is well-formed: tags match, attributes are quoted and there's a single root element. It doesn't check it against an XSD or DTD schema.
Will formatting change my data?
Only the whitespace between tags. Text, attributes, CDATA and comments stay the same, and elements with mixed text and tags are left exactly as written.
How do I minify XML?
Tick Minify instead. Whitespace between tags and comments are removed, and the status bar shows how much smaller the result is.