XML Viewer & Formatter
Paste or upload XML to validate, pretty-print, and explore it with an interactive tree view. Everything runs in your browser — your data never leaves your device.
Input
What is XML?
XML (eXtensible Markup Language) is a text-based format designed to store and transport structured data. Unlike HTML, XML has no predefined tags — you define your own to describe your data. It is widely used in web services (SOAP, REST), configuration files, office documents (DOCX, XLSX), RSS/Atom feeds, SVG graphics, and Android layouts.
An XML document consists of elements (tags), attributes (key="value" pairs inside tags), text content, CDATA sections, and comments. Every XML document must have exactly one root element and all tags must be properly closed and nested.
XML Example
<?xml version="1.0" encoding="UTF-8"?>
<library>
<book id="1" available="true">
<title>Clean Code</title>
<author>Robert C. Martin</author>
<year>2008</year>
</book>
<!-- More books can be added here -->
</library>How to Use the XML Viewer
- 1
Paste or upload your XML
Copy your XML from an API response, config file, or anywhere else and paste it into the editor. Or click Upload file / drag & drop a .xml file from your computer.
- 2
Click "Format & Validate"
The tool parses your XML using the browser's built-in DOMParser. If there are errors it shows the exact parser message. If valid, you get the formatted output below.
- 3
Explore with Tree or Raw view
Tree view renders a collapsible, interactive node tree — great for navigating complex documents. Raw view shows the prettified XML text with proper indentation.
- 4
Copy or Download
Use "Copy" to grab the formatted XML to your clipboard, or "Download" to save it as formatted.xml.
Frequently Asked Questions
Is my XML data stored on your servers?
No. All parsing and formatting happens entirely in your browser using the native DOMParser Web API. Your data is never sent to our servers, logged, or stored anywhere.
What types of XML files are supported?
Any well-formed XML file works: .xml, .xsl, .xslt, .xsd (schemas), .svg, .plist, .rss, .atom, .config, .csproj, and more. The tool uses the standard XML MIME type (text/xml) for parsing.
Why is my XML invalid?
Common causes include: unclosed tags, mismatched tag names (XML is case-sensitive), missing quotes around attribute values, illegal characters in tag names, or multiple root elements. The error message will indicate the exact location of the problem.
What is the difference between XML and HTML?
HTML has predefined tags and is lenient about syntax (browsers auto-correct many errors). XML lets you define your own tags and is strict — every tag must be closed, attributes must be quoted, and the document must have exactly one root element.
Can I view SVG files with this tool?
Yes. SVG is an XML-based format, so you can paste or upload any .svg file to inspect its element tree, attributes, and structure.
What is a CDATA section in XML?
CDATA (Character Data) sections let you include text that contains characters that would otherwise be interpreted as markup (like < or &). Everything inside <![CDATA[ ... ]]> is treated as plain text.
What is XML?
XML (eXtensible Markup Language) is a W3C standard for encoding structured data as text. Unlike HTML, XML has no predefined tags — you define your own tag names to model any data domain: configuration files, data feeds, document formats (DOCX, SVG, PPTX), and inter-system messaging.
XML is strict by design: every opening tag must have a matching closing tag, attribute values must be quoted, and every document must have exactly one root element. A document that satisfies these rules is called well-formed; one that also matches a schema (XSD or DTD) is called valid.
XML vs JSON
| Feature | XML | JSON |
|---|---|---|
| Verbosity | High — opening and closing tags | Low — concise key-value pairs |
| Comments | Yes — <!-- comment --> | No native support |
| Attributes | Yes — <tag attr="val"> | No distinction from keys |
| Namespaces | Yes — xmlns: prefix system | No |
| Schema | XSD (XML Schema Definition) | JSON Schema |
| Primary use | Config, enterprise systems, office docs | REST APIs, web apps, NoSQL |
Anatomy of an XML Document
<?xml version="1.0" encoding="UTF-8"?>
<!-- XML Declaration + Comment -->
<library xmlns:dc="http://purl.org/dc/elements/1.1/">
<book id="1" lang="en">
<dc:title>Clean Code</dc:title>
<author>Robert C. Martin</author>
<price currency="USD">35.00</price>
<description><![CDATA[A handbook of <agile> software craftsmanship.]]></description>
</book>
</library>Key parts: XML declaration (encoding), namespace (xmlns:dc), elements (<book>), attributes (id=“1”), and a CDATA section for text with special characters.