Skip to content
jsonforge.app

XML to JSON

Convert XML — SOAP responses, RSS feeds, legacy exports — into JSON, keeping attributes and reporting parse errors.

XML input

Loading editor…

JSON output

Enter XML on the left to convert it.

What is XML to JSON?

An XML to JSON converter parses an XML document and produces the equivalent JSON object tree. This is the direction that comes up when you have to consume something you don't control: a SOAP web service response, an RSS or Atom feed, a bank or government data export, a sitemap, an Android or Maven configuration file, or any legacy integration that predates JSON APIs. The two formats do not map onto each other perfectly, which is what makes the conversion worth doing carefully rather than by hand. XML distinguishes between attributes and child elements while JSON has only keys, and XML has no way to say "this element is a list" — a container holding one item looks structurally identical to a container holding a single value. This converter keeps attributes rather than discarding them, prefixing each with @_ so it never collides with a real child element, and stores an element's own text content under #text when that element also carries attributes.

How to use XML to JSON

  1. Paste your XML into the left panel, or load an .xml file from disk using the folder icon in the side rail.
  2. The JSON tree appears on the right immediately — attributes appear as @_name keys, and an element's text content appears as #text whenever that element also has attributes.
  3. If the document is not well-formed, you get the validator's message together with the exact line and column, so you can find the unclosed or mismatched tag quickly.
  4. Copy the JSON, or hit swap to reverse the converter and generate XML from JSON instead.

Examples

Repeated sibling elements become an array

Input

<r><i>1</i><i>2</i></r>

Output

{ "r": { "i": [ 1, 2 ] } }

Attributes are prefixed, text content goes under #text

Input

<r><i id="5">hi</i></r>

Output

{ "r": { "i": { "#text": "hi", "@_id": "5" } } }

Common mistakes

  • Writing code that assumes a repeated element is always an array — when the source document happens to contain exactly one of them, the same key becomes a single value and the loop breaks in production on real data.
  • Overlooking the @_ prefix on attributes and looking up the bare name — the value is there, just under @_id rather than id.
  • Expecting numeric-looking text to stay text — a value like <i>1</i> is converted to the JSON number 1, so version strings and identifiers written as bare digits lose their string type.

Why use this tool

  • Runs entirely client-side — SOAP responses and legacy exports containing sensitive records never leave your browser.
  • Preserves attributes with a collision-proof @_ prefix rather than silently dropping them, which many converters do.
  • Validates before converting and reports the exact line and column of the problem instead of producing half-parsed output.

Frequently asked questions