Skip to main content
Developer Tools

XML Formatter & Validator

Pretty-print, minify, or validate XML — and convert it straight to JSON. Everything runs in your browser.

Input XML 318 B
Result
371 B
<?xml version="1.0" encoding="UTF-8"?>
<catalog>
  <book id="bk101">
    <author>Gambardella, Matthew</author>
    <title>XML Developer's Guide</title>
    <genre>Computer</genre>
    <price>44.95</price>
  </book>
  <book id="bk102">
    <author>Ralls, Kim</author>
    <title>Midnight Rain</title>
    <genre>Fantasy</genre>
    <price>5.95</price>
  </book>
</catalog>

How to Use

  1. 1. Paste your XML into the input panel.
  2. 2. Choose Format, Minify, or To JSON.
  3. 3. Adjust the indent size if you are formatting.
  4. 4. Copy the result or download it as a file.

About XML Formatting

Machine-generated XML — SOAP envelopes, RSS feeds, sitemaps, Android layouts, build manifests — usually arrives on a single line. Indenting it reveals the element hierarchy, which is what makes a structural mistake obvious at a glance.

Validation here means well-formedness: every tag closed, attributes quoted, exactly one root element. That is a different question from schema validity, which checks your document against a DTD or XSD and needs the schema itself.

Converting XML to JSON is lossy by nature, because the two models disagree. XML distinguishes attributes from child elements and has no native array; JSON has arrays but no attributes. The usual convention — used here — prefixes attributes with @, stores mixed text under #text, and creates an array only when two or more sibling elements share a name.

Working with other formats? Try our JSON Formatter, YAML to JSON, or JSON to CSV.

Frequently Asked Questions

Does this validate my XML?

It checks that the document is well-formed — tags balanced, attributes quoted, one root element — and reports the first parse error with its message. It does not validate against a DTD or XSD schema.

How is XML converted to JSON?

Elements become object keys, attributes are prefixed with @, and text content becomes #text when an element also has attributes or children. Repeated sibling elements are collected into an array.

Why does my converted JSON have arrays in some places but not others?

XML has no way to mark "this is a list", so a single <item> is indistinguishable from a list of one. This tool creates an array only when it actually sees two or more siblings with the same name — the standard convention, but worth knowing if your consumer expects a fixed shape.

Is my XML uploaded anywhere?

No. Formatting, validation, and conversion all run in your browser. Nothing is sent to a server.

Was this tool helpful?

Share: