ToolBrigadeToolBrigade

XML to JSON

Convert XML documents to JSON format online.

How to use this tool

  1. 1Paste your XML.
  2. 2Click Convert.
  3. 3Copy or download the JSON.

About XML to JSON

XML to JSON converts XML documents into JSON objects so modern JavaScript tooling, REST clients, and data pipelines can consume legacy payloads without a server-side transform step.

SOAP services, vendor EDI feeds, RSS streams, and older enterprise APIs still deliver XML in 2025. Rewriting a consumer to speak XML natively takes time; a quick local conversion unblocks prototyping, fixture building, and one-off data exploration without uploading production envelopes to an unknown third-party site.

Paste your XML into the input panel and click Convert. The JSON output appears in the right panel, ready to copy or download. Processing runs entirely in the browser using a client-side XML parser — no upload, no account.

The mapping from XML to JSON involves conventions that differ between libraries. Attributes typically become a dedicated key such as @attributes or are merged into the element object depending on the parser's configuration. Repeated sibling tags with the same name usually become a JSON array, but a single occurrence of that tag may become a plain object — a common source of bugs when downstream code always expects an array. CDATA sections and XML comments may be dropped or preserved as special keys depending on the implementation. Namespace prefixes survive as literal key characters unless the parser strips them.

Deep nesting in verbose XML schemas can produce JSON that is technically correct but hard to navigate. Flatten or reshape the output in a JSON formatter or code step before feeding it to an API that expects a flat payload. Validate the converted fixture against your schema before committing it to a test suite, because a single-element array versus object mismatch will cause silent failures in typed languages.

Code examples

JavaScript (DOMParser)

function xmlNodeToObj(node) {
  if (node.nodeType === 3) return node.nodeValue.trim();
  const obj = {};
  for (const child of node.childNodes) {
    const val = xmlNodeToObj(child);
    if (val) obj[child.nodeName] = val;
  }
  return obj;
}

Python (xmltodict)

import xmltodict, json

obj = xmltodict.parse(xml_string)
print(json.dumps(obj, indent=2))

Frequently asked questions

Different tools use different definitions and parsers, so small gaps are common. XML to JSON applies DOMParser tree walk into plain objects with one consistent browser-side rule set. Hidden characters, stricter syntax, or a different tokenizer usually explain the mismatch. Reduce the input to a minimal sample, then add pieces back until the difference appears. Match the rule your destination actually enforces.

Treat the error as a signal that this environment is stricter or configured differently. Browser APIs reject malformed structures early instead of guessing. Convert to a boring intermediate when it helps—plain UTF-8 text, PNG, WAV, or an unlocked PDF—then retry. If the intermediate works, the original encoding was the problem. Keep that minimal sample for the next regression check.

Runtimes disagree even when feature names match. Locales, parser strictness, codec builds, and library versions differ between your browser and CI. Export the exact bytes from XML to JSON, hash them, and compare in the pipeline. Align normalization steps so both systems see the same input. Use the browser result as a reference artifact, then make CI match it.

Desktop apps win on deep feature sets, batch farms, and specialized hardware paths. XML to JSON wins on zero install, private local processing, and speed for the everyday job on this page. Choose desktop software for multi-hour editorial work or exotic edge formats. Choose this tool when you need a correct result quickly without uploading. Many people do a quick pass here first, then open the heavy suite only if an edge case demands it.

Prefer XML to JSON whenever the input is personal, unpublished, customer-owned, or under NDA, because the core transform stays in your browser via DOMParser tree walk into plain objects. Cloud services can still help for formats your browser truly cannot decode, but you must trust their retention policy. Strip secrets before any upload. Privacy is usually the reason to stay local—not a longer marketing checklist.

Start from the best original input you still have. Change only what the destination requires. Prefer lossless intermediates when you must convert twice. Because the tool is local, iterate in small steps: tweak one setting, re-run, compare. Spot-check a short sample before batching anything important.

No account is required for normal use. The core xml to json transform runs in your browser on your device using DOMParser tree walk into plain objects. You get on-screen output, a copy action, or a download without a mandatory ToolBrigade upload for that step. Keep your browser updated. A few lookup utilities may call public reference APIs for live fields only—they still do not need your private documents.

Lighter text, code, calculator, and many image jobs work on modern phones. Large video encodes and huge PDFs are happier on a plugged-in laptop with more RAM. Fully client-side flows can continue offline once scripts are cached; live lookups still need network. If a run seems stuck, try a smaller sample, free memory by closing tabs, and confirm the input is not truncated. Prove the path on a short fixture before blaming the algorithm.

Related Tools