No tool matches “”

Try a format (“webp”, “mp3”) or a verb (“merge”, “compress”).

Loading index

↵to open

Developer Tools · Updated November 8, 2026 · Reviewed by FormatFlow Editorial

XML to JSON Converter

You can convert XML to JSON in your browser, with attributes as @ keys, repeated children as arrays, namespaces preserved and well-formedness errors reported with a line and column.

Runs in your browserFree · No sign-up · No watermark
XMLJSONRuns in your browser
Loading the tool…

Everything runs locally in this tab. No file is uploaded while the tool loads.

This tool runs in your tab. Nothing is uploaded and no copy is stored.

How files are handled

Key facts

Category
Developer Tools
Processing
In your browser — nothing is uploaded
Input formats
XML
Output format
JSON
Maximum size
Bound by the memory available to your browser tab
Requirements
Chrome, Edge, Firefox or Safari · JavaScript enabled
Price
Free, no account, no watermark
Last updated
Nov 8, 2026

SummaryXML to JSON is a free online developer tools tool. You can convert XML to JSON in your browser, with attributes as @ keys, repeated children as arrays, namespaces preserved and well-formedness errors reported with a line and column. XML and JSON describe the same kind of tree with different syntax, but a naive converter loses information: attributes vanish, repeated elements overwrite each other and namespaces collapse. This converter uses one predictable mapping instead. Attributes become keys with an @ prefix, child elements become keys with repeated names collected into arrays, and text inside an element that also has attributes or children is kept under #text. It runs in your browser — nothing is uploaded. It accepts XML and produces JSON. The maximum size is bound by the memory available to your browser tab.

At a glance

Formats
XML → JSON
Processing
In your browser
Max size
Device memory bound
Price
Free, no account
Updated
November 8, 2026
All Developer Tools

About XML to JSON

XML and JSON describe the same kind of tree with different syntax, but a naive converter loses information: attributes vanish, repeated elements overwrite each other and namespaces collapse. This converter uses one predictable mapping instead. Attributes become keys with an @ prefix, child elements become keys with repeated names collected into arrays, and text inside an element that also has attributes or children is kept under #text.

Namespaces are preserved by keeping the prefix in element and attribute names, and the xmlns declarations appear as ordinary attributes, so the document keeps its meaning. The XML is parsed with the browser's DOMParser, which reports malformed documents with a message and a position. Both the mapping options and the conversion run locally; nothing is uploaded.

What this tool does

The details that matter when you use XML to JSON for real work.
  • Predictable JSON shape

    Attributes become @ keys, repeated children become arrays, text-only elements become strings and empty elements become null, so the same XML always gives the same JSON.

  • Configurable attribute prefix

    Keep the default @ or type another prefix such as $ or _ when the receiving system reserves the @ character.

  • Array handling option

    Use arrays only for repeated children, or wrap every child element in an array when a downstream schema always expects lists.

  • Namespaces preserved

    Prefixed element and attribute names stay prefixed and xmlns declarations are kept as attributes instead of being silently dropped.

  • Well-formedness errors with position

    Malformed XML is reported with the parser message and the line and column where parsing stopped, not as a generic failure.

  • Copy, download, no upload

    Copy the JSON or download it as a .json file; the XML is read locally in the browser and never sent to a server.

How to use XML to JSON

No account, no installation — the whole job happens in this browser tab.
  1. 01

    Paste or load XML

    Paste the document into the input pane or load an .xml file from your device; files up to 10 MB are accepted.

  2. 02

    Set the mapping options

    Choose an attribute prefix and whether arrays are used only for repeated children or for every child element.

  3. 03

    Convert to JSON

    Press Convert. The XML is validated with DOMParser and converted into the predictable JSON shape described above.

  4. 04

    Review the result

    Read the JSON output, checking attribute keys, arrays and any #text fields, and fix parser errors if they are reported.

  5. 05

    Copy or download

    Copy the JSON to the clipboard or download it as a .json file named after the uploaded document.

Supported formats and limits

Input
XML
Output
JSON
Processing
Client-side, in your browser. Nothing is uploaded.
Maximum size
Bound by the memory available to your browser tab.
Requirements
Chrome, Edge, Firefox or Safari · JavaScript enabled

Limitations worth knowing

  • Comments, processing instructions and doctype declarations are ignored in the JSON output.
  • Text is trimmed and internal whitespace collapsed, so whitespace-only formatting and intentional edge spaces are lost.
  • Mixed content with several text and element runs is aggregated: all text goes into one #text value rather than keeping strict order.
  • Input is capped at 10 MB of XML and conversion runs on the main thread after a short yield.

Privacy and file handling

Your XML is read, parsed and converted entirely inside this browser tab. The document is never uploaded to FormatFlow or anyone else, no copy is stored and nothing leaves your device; closing the page clears the input and the JSON result.

Read the full privacy policy

XML to JSON FAQ

Short, direct answers to the questions people ask before using this tool.
How are attributes represented in the JSON?
Every attribute becomes a key on the element's object with the configured prefix, @ by default. <item id="7"> becomes {"@id": "7"}, and multiple attributes simply become multiple prefixed keys.
When is a #text key used?
#text appears when an element contains meaningful text and also has attributes or child elements, because there is no room for a bare string value in that object. A text-only element such as <name>Ada</name> becomes simply "Ada".
How are repeated child elements handled?
With the default option, one child of a name becomes a single value and two or more become an array under that key. Choose always arrays when every child element should be a list, even when it appears once.
Are XML namespaces preserved?
Yes. Element and attribute names keep their prefixes, so soap:Envelope stays soap:Envelope, and xmlns declarations are kept as ordinary attributes such as @xmlns:soap. The JSON therefore keeps both the prefixes and their declarations.
What happens to comments, CDATA and processing instructions?
CDATA content is treated as text and is preserved. Comments, processing instructions and the doctype are not part of the data model and are ignored; keep the XML file when those matter.
Does the converter trim whitespace in text?
Whitespace-only text between elements is ignored, and text content is trimmed and its internal whitespace collapsed to single spaces. That keeps pretty-printed XML from filling the JSON with indentation, at the cost of losing intentional leading or trailing spaces.
Why does my XML fail to convert?
The document must be well formed: matching tags, quoted attributes and a single root element. The message and the line and column from the browser parser point at the first problem, which is usually an unclosed or mismatched tag.
Is my XML uploaded anywhere?
No. The file is read with the File API, parsed with DOMParser and converted in this browser tab. Nothing is uploaded, stored or logged, and closing the page discards the input and the result.

Background reading

Format guides that explain the trade-offs behind XML to JSON.