XML Formatter & Validator: Pretty Print, Tree, XPath

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

Paste XML to get started
Shift + Enter to Copy · Shift + ← → for tabs
1

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

Operation
Result
Format: <catalog><book id="bk101">...
Indented with each tag on its own line
XPath: //book[price > 10]
Returns the full <book> element with its children
Convert: <user id="42"><name>Alice</name></user>
{"user":{"@id":"42","name":"Alice"}} (pretty-printed with 2-space indentation)
Minify: <?xml version="1.0"?> + indented document
One line, without the <?xml ?> declaration

When 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

Well-formed
Valid
Rules
basic XML syntax
well-formed + external DTD/XSD
Checked by
this tool, automatically
a dedicated XSD validation tool
Typical failure
an unclosed tag
an element outside the schema's defined structure

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.

References

Related Tools