XML Formatter & Validator: Pretty Print, Tree, XPath
Paste XML to pretty print or minify it, spot the line with the error, browse it as a tree, run XPath queries, diff two files or convert to JSON.
Updated November 2026
Reviewed by Rafael Duarte
How to format XML online
Six tools, one paste box
1. Paste your XML
The well-formedness check runs instantly: you get a VALID XML or INVALID XML badge, and the line with the error is highlighted.
2. Pick a tab
Format, Minify, Tree (collapsible view), XPath, Diff, or Convert (to JSON or CSV).
3. Copy or download
Click Copy, or Download to save the result: formatted.xml or minified.xml from Format and Minify, output.json or output.csv from Convert.
What this XML formatter can do
Six features built into one tool
Formatting and minifying
Indent with 2 or 4 spaces or a tab, with options to sort attributes, remove comments and collapse empty tags. Format keeps the <?xml ?> declaration; Minify drops it.
Interactive tree view
Collapse and expand nodes to navigate documents with 10+ levels of nesting.
XPath querying
Type an XPath 1.0 expression and see the matching nodes serialized back as XML (up to 100), or the number, string or boolean it returns.
XML diff
Normalizes both documents before comparing, so indentation differences never show up as false positives.
Convert to JSON/CSV
Export the XML structure to formats that are easier to consume in other tools or scripts.
Well-formedness check
Every paste is parsed with the browser's DOMParser; if it fails, the badge turns to INVALID XML and the offending line is highlighted.
Examples
<catalog><book id="bk101">...//book[price > 10]<book> element with its children<user id="42"><name>Alice</name></user><?xml version="1.0"?> + indented document<?xml ?> declarationWhen you'll reach for this tool
The most common scenarios among people who use it
Debugging SOAP responses
Enterprise APIs return SOAP as a single line — format it to make sense of the envelope and body.
Reading RSS/Atom feeds
Open the feed in your browser, view its source, and paste it here to see how items are structured and which fields are actually available.
Maven and Spring configs
pom.xml and application context files nest deeply — the tree view makes them navigable.
Comparing API versions
Use Diff to see exactly what changed between two XML responses from an API.
Hit an error? Start here
Confusing well-formed with valid
Well-formed just means the basic syntax rules are followed. Valid also means the document obeys an external DTD or XSD.
Expecting namespaces to be stripped
Prefixes and xmlns declarations are preserved exactly as written. They're never rewritten.
XPath returns nothing on XML with a default namespace
Sitemaps (xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"), Atom feeds and SOAP bodies put every element in a namespace, so //url finds 0 results. The XPath tab has no namespace prefixes to bind, so match by local name instead: //*[local-name()='url'].
A huge file freezing the browser
Above 10–20 MB, split the XML into smaller pieces or use xmllint from the command line instead.
Why use this XML formatter
It bundles six features into one place — formatting, minifying, tree view, XPath, diff, and conversion — instead of forcing you to juggle a separate tool for each operation.
Everything runs in the browser through the native DOMParser, which makes it safe for XML that contains credentials, internal SOAP payloads, or other sensitive configuration.
Deciding between formats for a new project? Our JSON vs XML guide compares the two.
Well-formed XML vs. valid XML
Two different levels of conformance
Frequently asked questions
It adds indentation and line breaks to make the markup readable — elements, attributes and values stay the same. Only whitespace changes: text inside an element is trimmed at both ends, mixed content (text with tags, like <p>Hi <b>you</b></p>) is kept intact on one line, and a <!DOCTYPE> loses its internal [...] subset if it has one. For digitally signed XML, keep the original.
No. Parsing, formatting, XPath queries, diffing, and conversion all run in your browser via DOMParser and document.evaluate. Your XML never leaves the device.
XPath is a query language for selecting nodes inside an XML document. For example, //book[@genre='Fantasy'] selects every <book> element that has that specific attribute. If your document declares a default namespace (sitemaps, Atom, SOAP), use //*[local-name()='book'] instead.
It normalizes both documents — formatting them with consistent indentation — before comparing, so differences in whitespace never show up as false positives. Additions appear in green, deletions in red.
Well-formed means the document follows the basic syntax rules: a single root element, properly closed tags, and quoted attribute values. Valid means it's well-formed AND conforms to a structure defined by a DTD or XSD schema.
No. The VALID XML badge means the document is well-formed: it parses, tags are closed and nested correctly, attributes are quoted. Checking it against a schema needs a dedicated XSD validator or a command such as xmllint --schema.
Yes — switch to the Convert tab, choose JSON or CSV, and the structure is exported instantly. Attributes are prefixed with @ in the JSON output so they stay distinguishable from child elements.
References
Related Tools
- JSON Formatter & Validator: Fix Errors, Tree View Developer Format, validate and minify JSON with errors shown by line and column, one-click fixes for trailing commas and quotes, and tree or graph views.
- SQL Formatter & Beautifier: Format SQL Queries Online Developer Paste a SQL query to get it indented, with uppercase keywords and one clause per line, or minify it. Works with MySQL, PostgreSQL and SQL Server syntax.
- CSS Minifier & Beautifier: Minify or Unminify CSS Developer Paste CSS to get the minified version and the bytes saved instantly. It also unminifies CSS back to readable code and keeps your last 20 results locally.
- CNPJ & EIN Generator: Alphanumeric CNPJ 2026 + Validator Developer Generate test CNPJs (numeric or the new alphanumeric format, with branches) and US EINs, plus CIF, Partita IVA and SIREN. Validator included, free.
- Fake SSN & CPF Generator for Test Data, with Validator Developer Generate test SSNs and Brazilian CPFs, plus NIF, DNI, Codice Fiscale, Steuer-IdNr and NIR. Bulk CSV/JSON export, fake identity and a live validator.