Skip to content

XML to JSON

Convert XML into clean JSON, with attributes and text handled predictably.

Quick Tool Overview

The XML to JSON converter maps attributes to @-prefixed keys, element text to #text or to the value directly, and repeated tags to arrays — the conventions most libraries use, applied visibly rather than silently.

What it does
Converts XML into structured JSON
You give it
Any well-formed XML document
You get back
Formatted JSON with attributes and text resolved
Best for
Modernising SOAP, feed and legacy-API responses
Developer Tools Free, unlimited use No sign-up Runs in your browser

About the XML to JSON

Turning XML into JSON means answering three questions that have no single right answer, and this converter answers them the way most libraries do — visibly, so you are not surprised. Attributes become keys prefixed with @. An element's own text sits under #text when it also has children, and becomes the value directly when it does not.

A tag that appears once becomes a single value; the same tag repeated becomes an array. That is the behaviour that catches people out, because a document with one <item> and a document with three produce different JSON shapes. Type detection is optional: with it on, "42" becomes the number 42 and "true" becomes a boolean, which is usually what you want and occasionally is not.

Key features of the XML to JSON

Attributes never collide

The @ prefix keeps an attribute separate from a child element of the same name, which is otherwise a silent data loss.

Repeated tags become arrays

The same tag twice produces an array. A tag appearing once cannot, which is a difference worth knowing before your code depends on it.

Mixed content handled

An element with both text and children keeps its text under #text rather than discarding one or the other.

Optional type detection

Turn it on for real numbers and booleans, or off when a value such as 0700 must keep its leading zero.

Namespaces preserved

A prefixed name such as soap:Body becomes the key "soap:Body", so nothing is quietly stripped.

How to use the XML to JSON

  1. 1

    Paste your XML

    A feed, a SOAP response, a config file or an export.

  2. 2

    Set the conventions

    Choose the attribute prefix and whether to keep attributes at all.

  3. 3

    Choose type handling

    Leave detection on for real numbers and booleans, or off to keep every value as a string.

  4. 4

    Copy the JSON

    The result is formatted and ready to paste into code or a test.

Frequently asked questions

Because XML cannot express "this is a list of one". A tag appearing once becomes a value and the same tag repeated becomes an array — so code reading the result should handle both.

Reviews of the XML to JSON

What people who use the XML to JSON think of it. Reviews come from visitors and are posted as written.

No ratings yet

Yours would be the first.

  • 5 0 reviews rated 5 stars
  • 4 0 reviews rated 4 stars
  • 3 0 reviews rated 3 stars
  • 2 0 reviews rated 2 stars
  • 1 0 reviews rated 1 star

Write a review

Used this tool? Your rating helps the next person decide.

Your rating

Plain text only — links, email addresses and HTML are not accepted. Your name and review are shown publicly; nothing else is collected. See the privacy policy.

0 reviews

Newest first

No reviews yet

Be the first to rate the XML to JSON. It takes half a minute and no account.

Write the first review

More developer tools