Convert XML to JSON — Elements to Keys, Arrays Included

DataFileConverter parses an XML file and writes JSON: elements become keys, repeated elements become arrays, attributes are kept only if you ask. One file to one JSON, a folder in batch, or many files merged into one array. Desktop app for Windows, Linux and macOS — GUI and command line, nothing uploaded.

Download DataFileConverter

Key Features

Elements to keys

The root becomes an object, child elements become keys, and text content becomes the value — a mapping you can preview before writing.

Repeated elements become arrays

<item> appearing five times produces a JSON array of five objects instead of five colliding keys.

JSON, JSON array or JSONL

Write a single JSON document, a bare array of records, or one object per line for stream processing.

Batch, merge, CLI

One .json per XML file, a merged array, or a scheduled command line on Windows, Linux and macOS.

How to Convert XML to JSON (GUI Mode)

  1. Pick the direction
    New task → From Files / XML → To File / JSON. 📷
  2. Load the XML
    A single file, several, or a folder; the parsed element tree is previewed. 📷
  3. Choose the mapping
    Which element is the record, whether attributes are kept, and whether repeated elements become arrays. 📷
  4. Write and validate
    The output is JSON you can open in any editor or load with json.load; check the first record before handing it on. 📷

What the XML becomes in JSON

XML is a tree with attributes and text nodes; JSON has objects, arrays and values. The conversion is that mapping — and the first decision (which element repeats) is what makes the difference between a clean array and a nest of objects.

XMLJSON
<order><id>1001</id><total>129.90</total></order>{"order":{"id":"1001","total":"129.90"}} — elements become keys
<item>…</item> repeated under one parentan array: {"items":[{"…"},{"…"}]}
<order id="1001">{"order":{"@id":"1001", …}} when attributes are kept; ignored otherwise
text-only element <name>ACME</name>"name":"ACME" — the string, not an object
<br/> or mixed contentan ordered array of text and element objects, which most consumers dislike — check that record
xmlns:ns="…" on a parentthe prefix stays part of the key (ns:field) unless you strip it in the source configuration
<![CDATA[…]]>the text content, unescaped; a JSON string escapes quotes and newlines itself

Why Choose Our XML to JSON Converter?

CLI & Automation Support

Save the task once, then parse XML to JSON from a .sh on Linux or macOS, or a .bat on Windows. That is the usual shape: an export lands in a folder, a cron (or launchd / Task Scheduler) job runs one line, and the JSON is ready for the API or the loader. The CLI prints one line per file, so a broken file is visible in the log instead of silently missing.

The unit of reuse is the saved task file, not the command: the session records the mapping (row element, attributes, JSONL or array), so a scheduled run only has to point at a different input folder. That is what makes the same job usable for a daily drop and for a one-off backfill — and why the run is worth checking by exit status rather than by eye.

Other targets from the same source: XML to CSV, XML to Excel, XML to TXT and XML to TSV; the reverse direction is JSON to XML.

What breaks in real XML files

Check three things before you hand the JSON over

Frequently Asked Questions (FAQ)

Are XML attributes kept in the JSON?
Only if you turn them on: they are written with a prefix (commonly @id) so they cannot collide with a child element of the same name. Turn them off and the attribute is dropped.
Why is my repeated element an object instead of an array?
Because that file contained the element once. The mapping follows the data — if a list must always be an array, force the array output (which writes [] for single records too).
Can I convert XML to JSON on Linux or macOS from the command line?
Yes. Save the task once and run it from a .sh script (or a single command line); cron and launchd can run it unattended, and the .deb installs on Debian, Ubuntu and Linux Mint.
Can I get JSONL or a bare array instead of a document?
Yes — the output shape is a setting: a single JSON document, an array of records, or JSON Lines with one object per line.
Can I merge several XML files into one JSON array?
Yes. Choose a single .json target: each file's records are appended into one array, in file-name order.
What about Android XML or SOAP responses?
Both are ordinary XML. SOAP envelopes convert with the Envelope/Body wrapper as keys (unwrap in your consumer), and Android layouts are deep trees — pick the repeating element instead of the root.
How large an XML file can it parse?
Files over 4GB are supported with low memory usage; the parsed records can be previewed before the JSON is written.
Is anything uploaded?
No. The conversion runs locally, so customer data never leaves the machine.

Start Converting XML to JSON Now

One file, a folder in batch, or a merge into one array — free trial, no credit card.

$75 one-time · volume discounts to $55 · 30-day money-back · pricing & licence terms

Download Free Trial