🏷️

XML Formatter & Validator

Pretty-print messy XML with proper indentation, validate it with clear error messages, minify it for production, or convert it straight to JSON β€” all processed locally in your browser.

βœ… Validates Syntax πŸ”„ XML β†’ JSON πŸ”’ 100% Private

🏷️ Where XML Lives On

  • SOAP & enterprise APIs
  • RSS & Atom feeds
  • SVG graphics & sitemaps
  • Android layouts, .csproj, pom.xml
  • Office documents (docx/xlsx)

πŸ’‘ Tips

  • Errors report the failing line
  • Attributes become "@name" keys in JSON
  • Minify before embedding in requests
  • Your data never leaves the browser

XML in 2026: Older Than JSON, Far From Dead

JSON won the web API war, but XML never left the building. SOAP services still run banking, insurance, and government integrations; every RSS feed, sitemap, and SVG file is XML; Android layouts, Maven's pom.xml, .NET project files, and Microsoft Office documents (a .docx is zipped XML) all speak it daily. When one of these lands in your editor as a single unreadable line β€” which is how systems typically emit it β€” you need exactly three operations: format it to see the structure, validate it to find what's broken, and often convert it to JSON to use in modern tooling. This page does all three.

Validation: What "Well-Formed" Actually Means

XML is stricter than HTML: every tag must close, tags must nest properly (<a><b></a></b> is fatal), attribute values must be quoted, and the five special characters (& < > " ') must be escaped as entities inside content. The single most common real-world error is a bare ampersand β€” a URL like ?a=1&b=2 pasted into an XML value breaks the document unless written as &amp;. The validator here uses your browser's native XML parser, the same engine that renders SVG and feeds, and reports the line where parsing failed. Note the distinction: this checks well-formedness (syntax); whether the document matches a specific schema (XSD) is a separate, stricter question that requires the schema file itself.

How the XML β†’ JSON Conversion Maps Structures

XML and JSON model data differently β€” XML has attributes, JSON doesn't; XML distinguishes child order, JSON objects don't β€” so any conversion picks conventions. This tool uses the widely adopted ones: attributes become keys prefixed with @, element text becomes the value directly (or a #text key when an element has both text and attributes), and repeated sibling elements collapse into a JSON array. So <item sku="A1" qty="2"/> becomes {"@sku": "A1", "@qty": "2"}, and three <item> siblings become an item array. The result drops into JavaScript, Python, or our JSON Formatter and JSON to CSV tools without ceremony. One caveat worth knowing: comments, processing instructions, and CDATA markers don't survive β€” JSON has no equivalent for them.

Frequently Asked Questions

Is my XML uploaded anywhere?

No β€” parsing, formatting, and conversion all run on your browser's built-in DOM parser. Enterprise payloads and config files stay on your machine.

Why does my document fail with "error on line 1"?

If the whole document is on one line, every error is "on line 1". Format what parses, or check the classic culprits in order: unescaped &, an unclosed tag, mismatched nesting, or a stray character before the <?xml?> declaration (often an invisible BOM).

Does formatting change my data?

Formatting changes only whitespace between elements. One nuance inherited from the XML spec: whitespace inside mixed text content is significant, and the formatter preserves it β€” so text values are never altered.

Can I convert JSON back to XML?

Not here β€” JSON-to-XML needs decisions this tool can't guess (root element name, attribute vs element for each key, array item naming). The XML β†’ JSON direction covers the common workflow: consuming legacy XML in modern JSON-first code.

Does it validate against my XSD schema?

No β€” browsers don't expose XSD validation. This tool guarantees well-formedness; schema conformance needs a tool that loads your XSD, like xmllint --schema or your IDE.

Is there a size limit?

Multi-megabyte documents format fine; very large files (tens of MB) may take a few seconds since the whole tree is parsed in memory.

Are namespaces (xmlns) preserved?

Yes β€” namespace declarations and prefixed element names (<soap:Envelope>) survive formatting and minification intact, since they're structurally just attributes and qualified names. In the JSON conversion, prefixed names become keys as-is ("soap:Envelope").

Why does the output differ slightly from my input?

The formatter normalizes representation without changing meaning: empty elements become self-closing (<item/>), attribute values get double quotes, and inter-element whitespace is rebuilt. A round-trip through any standards-compliant parser produces the same document either way.

Done!