XML Formatter
Pretty-print and validate XML with syntax highlighting. Also minifies to a single line.
About the XML Formatter & Validator
XML (eXtensible Markup Language) is a markup language for storing and transporting structured data. Unlike HTML, XML tags are not predefined — you define your own element names to describe your data. XML is the foundation of SVG, RSS, SOAP web services, Microsoft Office file formats (.docx, .xlsx), Android layout files, and many enterprise data standards.
Well-formed vs valid XML
- Well-formed — follows basic XML syntax: all tags are properly nested and closed, attribute values are quoted, there is exactly one root element, and special characters (< > &) are escaped.
- Valid — additionally conforms to a Document Type Definition (DTD) or XML Schema (XSD) that defines allowed elements and attributes.
Most common XML errors
Unclosed tags, unescaped ampersands (write & not &), multiple root elements, mismatched tag names (XML is case-sensitive: <Item> differs from <item>), and missing quotes around attribute values are the most frequent mistakes that cause XML parsers to fail.
Real-world XML formats you encounter
XML is far from obsolete — it underlies many formats you use daily. Understanding these helps when debugging or transforming data.
- OOXML (.docx, .xlsx, .pptx) — Microsoft Office files are ZIP archives of XML files; unzip to inspect
- SVG — scalable vector graphics are XML; edit them in a text editor
- RSS/Atom — news feed formats used by podcasts, blogs, and content aggregators
- SOAP — legacy web service protocol; requests and responses are XML envelopes
- Android layouts — activity_main.xml files define UI hierarchies in Android development
Frequently Asked Questions
<root xmlns:h="http://example.com/html">. The URL is just a unique identifier — it does not need to resolve to anything. Namespaces are essential in compound document formats like OOXML (.docx).xmllint --format input.xml. Using Python: python3 -c "import xml.dom.minidom,sys; print(xml.dom.minidom.parse(sys.argv[1]).toprettyxml())" input.xml. Using pandoc: pandoc -f html -t plain input.xml.