Skip to content
QuickUtils

XML to JSON

Convert XML to readable JSON: attributes become @name keys, text beside them #text, and repeated elements lists. Namespaces and CDATA are kept, and DOCTYPE entities are never expanded.

Tip: choose several files at once to process them all with the same settings.

How to use it

  1. 1Choose or drop an XML file, or paste the XML.
  2. 2Choose whether repeated elements are always lists, and whether to indent.
  3. 3Copy the JSON or download it as a .json file.

Frequently asked questions

How are XML attributes written in JSON?

An attribute becomes a key starting with @, such as @id. Text in an element that also has attributes or child elements goes under #text, and an element with only text becomes that text.

Why is an element sometimes a list and sometimes not?

By default an element becomes a list only when it appears more than once in the same place. Choose Always a list if your code needs the same shape every time.

What happens to namespaces and CDATA?

Namespace prefixes stay in the names, such as soap:Body, and CDATA sections are read as plain text.

Is it safe to open an XML file someone sent me?

Yes. DOCTYPE declarations are skipped and their entities are never expanded, so tricks like the billion laughs attack do nothing.

Can't find what you need?

Please don't include names, numbers or other personal details.