Skip to the content

Contact usFree tools · No signup · Files stay on your device

XML to JSON Converter

Paste XML or open a file and get clean JSON. You decide how attributes, repeated elements and namespace prefixes are written, and any XML mistake is shown with its line and column.

  • PrivateYour data never leaves this device
  • No uploadsProcessed in your browser, not on a server
  • 100% freeNo signup, no watermark, no trial
  • UnlimitedUse it as often as you like, no daily caps

How we protect your privacy →

Options

XML input

JSON output

Output appears here.
Need the reverse? JSON to XML converter
Was this tool helpful?
How it works

How to use the XML to JSON.

4 short steps. Nothing to install, nothing uploaded.

  1. 1

    Paste your XML, click Open file, or press Sample to try it.

  2. 2

    Pick a convention: Simple (repeated names become arrays) or Always arrays, then choose how attributes are written.

  3. 3

    Optionally convert numbers, booleans and null, trim whitespace, drop namespace prefixes and set the indent.

  4. 4

    Copy the JSON or download it as a .json file. If the XML has an error, click Go to error to jump to it.

Guides

Guides for XML to JSON

All

XML to JSON: the complete guide to converting XML data

Learn how to convert XML to JSON online: how attributes, text, repeated tags and namespaces are written, what each option does, and what JSON cannot…

XML Formatter: the complete guide to validating and beautifying XML

A complete guide to formatting XML online: beautify or minify, pick the indent, sort attributes, strip comments, and read every well-formedness error…

JSON to XML: the complete guide to converting JSON data

How to convert JSON to XML online: how arrays, @attributes and #text are written, why a root element appears, how invalid key names are fixed, and…

Word to Text: the complete guide to getting plain text from Word files

How to get plain text out of a Word .docx file: how headings, lists, tables and links are laid out, how to wrap lines at 72 or 80 characters, and what…

Word to Markdown: the complete guide to converting DOCX to MD

How to convert a Word DOCX to GitHub-flavoured Markdown: headings, lists, tables, escaping, pictures and page breaks, and what Markdown cannot keep…

Word to HTML: the complete guide to clean HTML from DOCX

How to convert Word to clean HTML: full page or body only, minimal, inline or no styles, pictures, tables and lists, plus what is not carried over…

Page 1 of 19
Questions

Frequently asked questions.

Quick answers about the XML to JSON.

How are XML attributes and text written in JSON?
Attributes become keys starting with @ (or _, or one $attrs object if you prefer), so id="1" becomes "@id": "1". An element with only text becomes a string; if it also has attributes or child elements, its text goes into a "#text" key. An empty element becomes null.
What happens with repeated elements?
In Simple mode a name that appears more than once becomes an array, and a name that appears once stays a single value. That is compact, but the shape depends on the data. Choose Always arrays and every child element is an array, so code reading the JSON never has to check which one it got.
Are numbers and booleans converted?
Not unless you tick the option, because XML has no types and 007 or 1e5 might be an ID rather than a number. With it on, plain numbers, true, false and null become JSON values; values with leading zeros and integers too large to be exact stay as text.
Does it handle namespaces, CDATA and DOCTYPE?
Yes. Prefixed names such as ns:item are kept as written, or you can drop the prefixes. CDATA is treated as text, and comments and processing instructions are left out because JSON has no place for them. A DOCTYPE is accepted, but entities it defines are never expanded.
Is it safe to paste XML from an untrusted source?
Yes. The parser runs in your browser and never expands custom or external entities, so XXE and entity-expansion (billion laughs) attacks do nothing. Very large or very deeply nested input is rejected with a clear message.
Can I convert JSON back to XML?
Yes. The JSON to XML converter reads the same conventions (@ for attributes, #text for text), so a document converted with the Simple option round-trips with its structure intact. Interleaved element order and comments are the two things JSON cannot keep.