esc
XML → JSON

XML to JSON
Converter

XML to JSON. Free, private, instant.

Reverse JSON → XML

Quick steps

  1. 01Add XML filesChoose files or drop them on the page.
  2. 02Converted on your deviceNothing is uploaded. Adjust settings if you like.
  3. 03DownloadSave each file, or all of them as one ZIP.
File character sorting nested brackets into rows

What’s XML?

A tag-based data format used by feeds, configs and older APIs.

XMLTagged data
JSONNested data

Convert XML files into readable JSON, with attributes, text and repeated elements mapped in a consistent way. The XML is checked and converted in your browser, so nothing is uploaded, and it costs nothing.

How to convert XML to JSON

  1. Click Choose files or drop .xml files onto the page.
  2. Each file is validated and converted as soon as it’s added.
  3. Choose an Indent in the settings panel on the right (2 spaces, 4 spaces or Minified) and click Apply to all files if you change it.
  4. Save the .json file, or Download all (.zip).

How XML maps to JSON

XML and JSON don’t line up one to one, so the converter follows a fixed set of rules. Knowing them makes the output easy to work with.

The root element becomes the single top-level key. Each child element becomes a key inside its parent. When an element appears more than once in the same parent, its values are collected into an array; when it appears once, it’s a plain value or object.

Attributes become keys that start with @_, so id="7" turns into a key named @_id. When an element has both attributes and text, the text goes under a key named #text.

Namespace prefixes are kept in the key names, so dc:title stays dc:title.

Values, whitespace and what gets dropped

  • Element text that looks like a number becomes a JSON number, and true and false become booleans. Numbers with leading zeros, hex values and exponent notation like 1e5 stay strings, so codes and IDs aren’t altered.
  • Attribute values are always kept as strings.
  • Whitespace at the start and end of text is trimmed.
  • Comments, the XML declaration and processing instructions are left out.
  • CDATA sections are merged into the element’s text.

Common problems and fixes

  • “This isn’t valid XML (line 14, column 3).” The file is checked before converting. The message points to the problem, often an unclosed tag, a stray ampersand that should be written as &, or two root elements.
  • A field is sometimes an object and sometimes an array. That follows from the rule above: one child gives a value, two or more give an array. In your code, wrap single values in an array before looping.
  • Mixed text and tags lose their order. In XML like a paragraph with bold words inside, the text and the child elements are stored under separate keys, so the original order isn’t kept. This tool is meant for data XML (feeds, exports, configs), not for documents.

When to use it

Typical jobs are reading an RSS or Atom feed in JavaScript, moving settings out of an old XML config, inspecting a SOAP response or an export from older business software, and preparing sample data for tests. JSON is easier to read and works directly in JavaScript and most modern APIs.

To go back, JSON to XML uses the same @_ and #text conventions, so a converted file can be turned back into similar XML.

The whole file is read into memory at once. Exports of tens of megabytes are fine on a computer; very large database dumps may be too much for a browser tab, especially on a phone.

Privacy

Validation and conversion both run in your browser using fast-xml-parser. The files stay on your device, which is useful for exports that contain customer or company data.

Guides

JSON vs CSV vs XML: which to use and how to convertA plain-English comparison of JSON, CSV and XML: what each is good at, when to pick which, and how to convert between them without losing data.

At a glance

Price
Free. No sign-up, no watermark.
Privacy
Files are processed in your browser and never uploaded.
Accepts
XML
You get
JSON
Batch
Convert many files at once and download them as a ZIP
Works in
Chrome, Edge, Firefox and Safari, on phones and computers
Offline
Keeps working without internet once the page has loaded

Questions

Are my files uploaded?

Never. XML to JSON conversion runs in your browser, so your files stay on your device.

Can I convert many at once?

Yes. Add as many as you like and download them all as one ZIP.

Is there a size limit?

Files of tens of megabytes are fine on most computers.

How are XML attributes shown in the JSON?

As keys starting with @_, placed next to the element’s child elements. An element’s own text goes under #text when it also has attributes.

Why is one element an object and another an array?

Elements that repeat inside the same parent become arrays; elements that appear once stay single values.

What happens to comments and CDATA?

Comments are dropped. CDATA content is kept as part of the element’s text.

Are namespaces kept?

The prefixes are kept in the key names, such as dc:title. Namespace declarations appear as @_ attribute keys.

Does it check whether my XML is valid?

Yes. Invalid XML is rejected with the line and column of the first problem.