Skip to content

Data Converter

Convert XML to JSON

Convert XML elements, attributes, repeated tags, and text into a readable JSON structure.

100% In-Browser & PrivateNo uploadsFree forever

Convert well-formed XML to JSON locally. Repeated sibling elements are grouped into arrays, attributes use an `@_` prefix, and namespace-qualified names remain qualified.

Text-only elements become strings. Elements with both attributes and text use `#text`; mixed text or interleaved repeated elements use an ordered `#content` array so sequence is retained.

XML has features JSON cannot represent directly. DTDs and custom entities are rejected for safety, comments and processing instructions are ignored, and ordinary text remains a string rather than being guessed as a number or boolean.

XML attribute and repeated-element mapping

<catalog>
  <book id="b-1">Algorithms</book>
  <book id="b-2">Compilers</book>
</catalog>

How to convert XML to JSON

  1. 1Paste XML, load the sample, or drop an XML file into the input editor.
  2. 2Convert the document. Malformed XML reports a line and column when available.
  3. 3Review attributes, repeated-element arrays, namespaces, and mixed-content output.
  4. 4Copy or download the formatted JSON result.

Why MyJSONPal is different

Privacy-first, by design

All parsing, validation and conversion runs in your browser. Your data is never sent, logged, cached or sold — close the tab and it is gone.

Fast, even on huge files

Heavy processing is offloaded to a Web Worker, so multi-megabyte documents are handled without freezing the interface.

No accounts, no limits

There is nothing to sign up for and no usage quota. Paste, format, convert and download as often as you like.

Frequently asked questions

How do I convert XML to JSON online?

Paste XML or load the sample, then select Convert to JSON. Review the output and copy or download it; conversion runs locally in your browser.

How are repeated XML elements represented in JSON?

Sibling elements with the same name become an array. For example, repeated `<book>` children become a `"book": [...]` property.

Where do XML attributes appear in the JSON output?

Attributes use the `@_` prefix, so `<book id="b-1">` becomes a book object with `"@_id": "b-1"`.

How do I convert XML to JSON in Java?

Use Jackson’s jackson-dataformat-xml module: read XML into a JsonNode with XmlMapper, then serialize that tree with ObjectMapper. For a one-time conversion without Java setup, paste the XML into this online converter.

When should I use XML vs JSON?

Choose XML for document markup, namespaces, mixed content, or integrations that require an XML schema. Choose JSON for lightweight web APIs and JavaScript data exchange; this tool converts XML when a JSON workflow is more suitable.

Why are documents with a DOCTYPE rejected?

DTD declarations can define custom entities and trigger entity-expansion attacks. The converter disables entity processing and rejects DOCTYPE declarations instead of resolving them.