About XML to JSON Converter
Turn an XML feed, a SOAP response, a config file or an export into JSON that a script or an API can use. Elements become keys, repeated elements become lists, and attributes become keys with a prefix such as @id, sit under one @attributes key, or are left out.
You decide whether an element holding only text becomes a plain value or an object, whether every child becomes a list so the shape never changes with the data, and whether numbers and true or false are typed. A document that is not well formed is reported with the line and column of the first problem.
How it works
- The XML is first checked for well-formedness: matched tags, quoted and unique attributes, legal names and references. The first problem is reported with its line and column.
- The five predefined entities and numeric character references are expanded. Entities a DOCTYPE defines are kept as written and pointed out, so no document can expand itself into gigabytes.
- CDATA sections become ordinary text, exactly as written. Comments, processing instructions and the XML declaration are left out.
- Text that sits beside child elements goes under the text key. Its position among the children is not kept, as JSON objects have no order between keys of different names.
Questions
Why is a single element sometimes a list and sometimes not?
By default only repeated elements become lists, so one <tag> gives a value and two give a list. Set Lists to Always to make every child element a list, which keeps the shape the same whatever the data holds.
Are numbers converted?
Only if you turn on Detect numbers and booleans. Even then, values with leading zeros such as postcodes, and numbers with more than 15 significant digits, stay text so nothing is changed.
What happens to namespaces?
Prefixed names are kept as written, such as soap:Body, and xmlns declarations are kept as attributes, so nothing is lost or guessed.
How large a document can it convert?
Up to 5 MB of XML, nested up to 1,000 levels deep. The conversion runs on your device as you type.
Everything you enter here is processed in this browser tab. Nothing is uploaded, logged or shared. How privacy works here.