XML to JSON Converter
Convert XML to JSON. Element names become object keys, attributes get a configurable prefix (@, _, or none), text content gets a configurable key name, and repeated sibling elements become a JSON array automatically — with an option to force every element into an array so the shape never depends on how many times it repeats. Runs entirely in your browser.
Input
Options
The key used for an element's own text when it also has attributes or child elements.
Wrap every child element in an array, even ones that appear only once, so the shape never depends on how many times an element repeats in a given document.
Output
Guides
Paste XML, get JSON. This free online XML to JSON converter turns an API response, an RSS/Atom feed, an app config, or any other XML document into clean, structured JSON — the format almost every modern API, script or JavaScript app actually expects. Conversion happens as you type, with no upload and no sign-up.
How to use it
- Paste your XML into the input box, or drop an
.xmlfile onto the uploader. - Choose an attribute prefix (
@,_, or none) to control how XML attributes appear as JSON keys. - Pick a text content key (
#text,_text, ortext) — used when an element has attributes or child elements alongside its own text. - Toggle trim whitespace and always represent child elements as arrays to match the shape your downstream code expects.
- Pick an indent (2 spaces, 4 spaces, tab, or minified) and copy or download the result as
converted.json.
The output updates automatically as you type.
How does XML map onto JSON?
Every element name becomes an object key. An element with no attributes and no child elements — just text, like <founded>1995</founded> — collapses to a plain JSON string. An element with attributes and/or children becomes a JSON object: attributes become sibling keys carrying your chosen prefix (@id, _id, or plain id), child elements become nested keys, and any of the element's own text is stored under your chosen text key (default #text) alongside them. Sibling elements that share the same tag name automatically become a JSON array, in document order — a <department> that appears three times under <departments> becomes "department": ["Engineering", "Design", "Marketing"].
Why does "always represent child elements as arrays" matter?
Without it, whether a given tag ends up as a plain object/string or an array depends entirely on how many times it happens to repeat in this particular document — a <book> catalog with one book gives you an object, but the same catalog with two books gives you an array, and code that reads catalog.book.title breaks the moment a second book shows up. Turning this on wraps every child element in an array unconditionally, even a single occurrence, so the shape is predictable regardless of how many times an element actually repeats.
What happens to XML comments, CDATA and the <?xml ... ?> declaration?
Comments and the XML/processing-instruction declarations carry no data and are dropped from the JSON output. CDATA sections are treated as plain text content — their contents are read literally (no entity decoding) and folded into the element's text the same way ordinary text would be.
Are values typed as numbers or booleans?
No — every attribute and text value converts to a JSON string, exactly as written in the XML ("1995", not 1995). XML has no native type system beyond the schema you bring to it, so guessing at numbers/booleans risks mangling values like IDs, version strings or ZIP codes that happen to look numeric. If you need typed values downstream, cast them there where you control the schema.
What if my XML is malformed?
The converter parses XML well-formedness — matching tags, a single root element, properly quoted attributes — and reports a clear error naming the specific problem instead of guessing at broken markup or silently producing garbage JSON. Fix the issue it names and the output regenerates automatically.
Is my data private?
Completely. Parsing runs entirely in your browser using a self-contained XML parser — your data is never sent to a server, logged, or stored, which matters for XML that carries API payloads, internal config or anything else you'd rather not upload anywhere.
What's the inverse of this tool?
The JSON to XML Converter does the reverse conversion, turning a JSON document back into XML markup.