Lintify Logo
Lintify
Converters

XML to JSON Converter

Parse XML back into JSON with configurable attribute prefixes, text node handling, and array coercion. Great for legacy API migration.

XML input
1
JSON
Output will appear here…

Convert XML back into JSON

XML and JSON represent data very differently. XML has attributes, text content, mixed content, namespaces, and processing instructions — none of which have a direct equivalent in JSON. Converting XML to JSON is therefore lossy: you have to make decisions about how to represent each XML feature in JSON. Lintify uses sensible defaults that work for most modern XML, but understanding those decisions helps you interpret the output correctly.

The converter uses fast-xml-parser, a popular JavaScript XML library. Attributes are turned into JSON keys with a configurable prefix (default@), so an attribute id="42"becomes {"@id": "42"}. The prefix is necessary so that attributes and child elements with the same name do not collide in the resulting object.

How text content is handled

XML elements can have both text content and child elements — JSON has no equivalent of this "mixed content". Lintify uses a configurable key (default#text) for the text content of an element. If an element has only text and no children, you can configure the converter to collapse the element to a plain string value, which produces cleaner JSON when you do not need to preserve the attribute-or-text distinction.

How arrays are represented

XML does not distinguish between a single child element and a list of one element. <user>Ada</user>could be a single user or a list with one user. Lintify treats repeated tag names as arrays — if the same tag appears multiple times as a child of the same parent, the values are collected into a JSON array. If a tag appears only once, it is a single object. This matches what most consumers expect.

Namespaces and CDATA

Lintify preserves namespace prefixes as part of the element name — soap:Envelope stays as the keysoap:Envelope. It does not resolve namespace URIs to fully-qualified names because that requires an external schema and is rarely what you want when converting XML to JSON. CDATA sections are treated as text content of the parent element and merged with any surrounding text. The CDATA wrapper itself is not preserved because JSON has no equivalent concept.

Frequently asked questions

Common questions about the XML → JSON tool.

How are XML attributes represented in JSON?
XML attributes are turned into JSON keys with a configurable prefix. The default prefix is @, so an attribute id="42" becomes "@id": "42". The prefix is necessary so that attributes and child elements with the same name do not collide in the resulting object.
What happens to the text content of an element?
By default, the text content of an element becomes a special key named #text. If an element has only text and no children, Lintify can be configured to collapse the element to a plain string value, which produces cleaner JSON when you do not need to preserve the attribute-or-text distinction.
How do I know if a child element should be an array?
XML does not distinguish between a single child element and a list of one element. Lintify can either always treat repeated tag names as arrays (the default) or always treat every child as an array. Pick the option that matches your consumer's expectations and review the output before shipping.
Are CDATA sections preserved?
Yes. CDATA content is treated as text content of the parent element and merged with any surrounding text. The CDATA wrapper itself is not preserved in the JSON because JSON has no equivalent concept — once the data is in JSON, the distinction between CDATA and regular text no longer matters.
Does it support XML namespaces?
Lintify preserves namespace prefixes as part of the element name (for example, soap:Envelope stays as the key soap:Envelope). It does not resolve namespace URIs to fully-qualified names, because that requires an external schema and is rarely what you want when converting XML to JSON for downstream processing.

Related tools