XML to JSON Converter — Attributes, Repeated Elements and Text

Developer Tools

Loading tool...

About This Tool

Convert one XML document to JSON with optional attributes and whitespace trimming. Inspect repeated elements, inferred values and conversion limits.

How to Use

  1. Paste one well-formed XML document.
  2. Choose whether to include attributes and trim text.
  3. Convert and inspect the JSON or parsing error.
  4. Copy the result after checking inferred values.

How XML maps to JSON

The document root becomes a JSON key. Repeated sibling elements become arrays, including empty, zero and false values. Attributes use an @ prefix when enabled. Text and CDATA are retained; text alongside attributes or child elements uses #text.

Values and limitations

Leaf text matching true, false or null becomes the corresponding JSON value. Numeric text is inferred automatically, except unsafe integers, which remain strings. Leading zeros can be lost and decimals follow JavaScript number precision. There is no separate type-inference toggle.

Not a reversible XML format

Only one document is accepted. Mixed text is combined, so its order relative to elements is not preserved. Comments, processing instructions and namespace semantics are not fully represented. Trimming changes text whitespace. Use this for inspecting structured data, not lossless XML storage. Shared services appear in the privacy policy.

Frequently Asked Questions

Can I paste several XML documents together?
No. Submit one well-formed document with a single root.
Does conversion preserve every XML detail?
No. Mixed-content order, comments and some XML semantics are not preserved.
Are types inferred?
Yes, automatically for leaf values. Review leading zeros and decimal precision; unsafe integers stay as strings.