What is XML?
XML (eXtensible Markup Language) is a text-based format for storing and transporting structured data. Unlike HTML, which uses a fixed set of tags, XML lets you define your own tags to describe any kind of data. It’s used in configuration files, data interchange between systems, document formats (like Office files), and many web services.
Like JSON, XML is often compressed for transmission — all whitespace stripped out — which makes it unreadable for humans. It also has strict syntax rules, and even a small mistake like an unclosed tag or a missing quote makes the document invalid.
What Does This Tool Do?
This tool formats and validates XML documents. It adds proper indentation and line breaks to make the structure clear, and reports any syntax errors it finds. Color-coded output makes it easy to distinguish tags, attributes, and content.
How to Use This Tool
- Paste your XML into the input area.
- The formatted result appears immediately.
- If there’s a syntax error, an error message indicates the problem.
- Copy the formatted output with the copy button.
- For large documents, switch the View control to Output to inspect the result at full width.
Common Use Cases
- Inspecting API responses: Many legacy APIs and SOAP services return XML — format it to understand the structure.
- Editing config files: Spring, Maven, Android, and many other tools use XML configuration files.
- Validating structure: Quickly check whether your XML is well-formed before using it.
- Working with data exports: Spreadsheet apps and databases often export data as XML.
The Rules of Well-Formed XML
XML’s strictness is a feature — it makes documents unambiguous — but it means the parser rejects things HTML would forgive:
| Rule | Wrong | Right |
|---|---|---|
| Every tag must close | <item>text | <item>text</item> |
| Empty elements self-close | <br> | <br/> |
| Attributes need quotes | <a href=x> | <a href="x"> |
| Exactly one root element | <a/><b/> | <root><a/><b/></root> |
| Tags are case-sensitive | <Item></item> | <Item></Item> |
Raw & and < forbidden in text | <q>a & b</q> | <q>a & b</q> |
| Proper nesting | <b><i></b></i> | <b><i></i></b> |
When the validator reports an error, it’s almost always one of these seven.
Escaping Special Characters
Five characters must be escaped in XML content: & (&), < (<), > (>), " (”) and ' (’). For blocks with many special characters — embedded code, formulas — wrap the content in <![CDATA[ … ]]> instead, which tells the parser to treat everything inside as literal text.
XML vs JSON: When You’ll Meet Each
JSON has won the API world, but XML remains everywhere: SOAP web services in banking and government, RSS/Atom feeds, SVG images, Android layouts and Maven/Spring configuration, Microsoft Office documents (a .docx is zipped XML), sitemaps, and invoice standards like NF-e. XML’s advantages — attributes, namespaces, schemas, comments — matter in document-centric and contract-heavy domains, which is exactly where it persists.
Frequently Asked Questions
What's the difference between well-formed and valid XML?
Well-formed means the XML follows basic syntax rules (all tags closed, proper nesting, etc.). Valid means the XML also conforms to a specific schema (DTD or XSD). This tool checks for well-formedness only.
Does it support XML namespaces?
Yes. Namespaces are preserved as-is in the formatted output.
Is my data private?
Yes. All processing happens locally in your browser — no data is sent anywhere.
What is a CDATA section?
<![CDATA[ … ]]> marks a block where the parser treats everything as literal text — no entity escaping needed. It’s the standard way to embed code snippets, scripts, or HTML fragments inside an XML document.
Why does my XML fail with "content not allowed in prolog"?
Something appears before the <?xml …?> declaration — usually an invisible UTF-8 BOM (byte order mark), stray whitespace, or leftover text from a copy-paste. Delete everything before the first < character and re-validate.