Advertisement

XML Formatter

Beautify and validate XML with the exact error line, minify it, or convert XML to JSON - in your browser.

Last updated:

XML Formatter
Beautify · Validate · Minify · To JSON
Paste XML and press Format. Runs in your browser.

How to Format and Validate XML

1
Paste XML, upload a file or press Sample
2
Press Format / Beautify; errors show the line and column
3
Copy, download, minify or press XML → JSON

Works with SOAP responses, RSS feeds, sitemaps, SVG, Android layouts and .config files.

What This XML Tool Does

ButtonWhat it doesAlso searched as
Format / BeautifyIndents nested elementsxml pretty print, xml beautifier, xml viewer
ValidateChecks the XML is well-formedxml validator, xml checker, xml lint
MinifyRemoves whitespace and commentsxml minifier, compress xml
XML → JSONTurns XML into JSONxml to json converter

Common XML Errors

ErrorCauseFix
Opening and ending tag mismatch<a></b>Close tags in the right order
Unescaped &Tom & JerryWrite &amp;
Unescaped <5 < 6 in textWrite &lt; or use CDATA
Extra content at the endTwo root elementsWrap everything in one root
Attribute without quotesid=5Use id="5"
Text before the declarationSpace before <?xmlThe declaration must be first

XML Rules in Short

How XML Maps to JSON

XMLJSON
<name>Sam</name>"name": "Sam"
<price currency="USD">9</price>"price": {"@currency": "USD", "#text": "9"}
Repeated <book> elements"book": [ {...}, {...} ]
Empty <tag/>"tag": ""

Format XML in Code and Editors

WhereHow
Linux / Macxmllint --format file.xml
Pythonxml.dom.minidom.parseString(s).toprettyxml()
VS CodeXML extension → Shift + Alt + F
Notepad++XML Tools plugin → Pretty print

Where You Meet XML

FileWhat it is
sitemap.xmlLists your pages for Google and Bing
RSS / Atom feedBlog and podcast updates
SOAP responseOlder enterprise and bank APIs
pom.xmlMaven build file (Java)
AndroidManifest.xmlAndroid app settings
.svgVector images are XML
web.configIIS / .NET settings

Related Tools

Frequently Asked Questions

How do I format XML online? +

Paste it above and press Format / Beautify. Choose 2 spaces, 4 spaces or tabs.

How do I validate XML? +

Press Validate. Errors show with the line and column, and the line is highlighted.

Does it validate against an XSD schema? +

No. It checks that the XML is well-formed. Schema (XSD/DTD) validation needs a server-side tool.

How do I convert XML to JSON? +

Press XML → JSON. Attributes become @name keys and repeated elements become arrays.

Can it format SOAP, RSS, sitemap or SVG files? +

Yes - they are all XML.

Is my XML uploaded? +

No. It is processed in your browser.

Does formatting change my data? +

No. Only whitespace between tags changes; values, attributes, comments and CDATA are kept.

How do I minify XML? +

Press Minify to remove whitespace between tags and comments.

About the creator Prajwal Karkera, creator of ToolsFlow

Built and maintained by Prajwal Karkera, a digital product specialist with 8+ years of experience in digital products. Found a problem with this tool? Let us know through the Contact page.
Read more about me →