consolelog.tools

XML to JSON

Convert XML to JSON live — decodes XML entities, optionally coerces numbers / booleans / null, and preserves attributes under @attributes.

About this ToolHow it works, benefits & use cases

Parse XML into clean, structured JSON directly in your browser, updated live as you edit. The converter reads elements into nested objects, and when a parent has several children with the same tag it collapses them into an array automatically — so repeated <user> or <item> nodes become a JSON list rather than overwriting one another. XML entities such as &amp;, &lt; and numeric character references like &#169; are decoded back to their real characters. Element attributes are preserved under an "@attributes" key by default, matching the convention the JSON to XML tool consumes so documents can round-trip. An optional type-coercion mode converts unambiguous text values — turning "42" into a number, "true"/"false" into booleans and "null" into null — while leaving everything else as strings. You can also drop attributes entirely if you only care about element content. The result shows how many elements were parsed and can be copied, downloaded as .json, or shared, with no upload.

How to Use

  1. 1Decide on your options: keep "Coerce types" on to turn numeric, boolean and null text into real JSON types, and toggle "Ignore attributes" if you want to discard XML attributes.
  2. 2Paste your XML into the input panel — the JSON regenerates live — or click "Load example".
  3. 3Press "Convert to JSON" to validate the XML.
  4. 4If the markup is malformed, read the parse error describing what went wrong, then fix the source.
  5. 5Copy the JSON, download it as output.json, or share it via the generated URL.

Key Benefits

  • Collapses repeated same-tag children into JSON arrays automatically
  • Decodes named and numeric XML entities back to real characters
  • Preserves attributes under "@attributes" for round-tripping with JSON to XML
  • Optional type coercion: numbers, booleans and null instead of strings
  • Option to ignore attributes when you only need element content
  • Reports the number of elements parsed; copy, .json download and sharing
  • Entirely client-side — your XML never leaves the browser

Common Use Cases

  • Consuming a legacy or SOAP XML API as JSON in a JavaScript app
  • Converting an RSS or sitemap feed into JSON for processing
  • Extracting structured data from a configuration or export file in XML
  • Inspecting attribute-heavy XML by viewing it as a JSON tree
  • Round-tripping documents alongside the JSON to XML converter

Options

42 → number, true → boolean, null → null

Drop XML attributes entirely

0 characters · live

Paste XML above to see the JSON live.

Was this tool helpful?

Share Your Experience

Help others discover this tool!

Related tools