JSON ⇄ XML Converter
Convert JSON and XML locally with explicit arrays, attributes and text while refusing lossy structures.
This tool runs entirely in your browser. Your data is never uploaded, never stored, and never leaves your device.
Converts a defined data-oriented subset of JSON and XML in both directions, preserving explicit arrays, nulls, attributes and element text while refusing structures that would be silently corrupted.
How to use it
- 1Choose the direction with the JSON → XML or XML → JSON button.
- 2Paste the document into the input box.
- 3Press Convert, then copy the result.
Example
- Input
- {"name":"Ada","age":36}
- Output
- <root data-json-type="object"> <name>Ada</name> <age data-json-type="number">36</age> </root>
Arrays use a wrapper marked data-json-type="array" with repeated <item> children. Attributes use @name and element text uses #text. Namespaces, DOCTYPEs, mixed content and interleaved repeated tags stop with an explanation rather than losing meaning.
What happens to your data
Both paths run on the string already in the textarea, with input, output, depth and node limits. The builder validates every portable XML name and character; DOMParser reads XML locally and the walker enforces the published mapping. No document is uploaded or retained.
Last updated September 2026
Something at the other end wants XML and everything you have is JSON — or the reverse, and a supplier feed or an old endpoint has arrived in angle brackets when your code expects objects. The difficult part is not drawing tags; it is preserving the facts JSON knows about arrays, objects, numbers, booleans and null when XML has no built-in versions of those types.
This converter publishes one explicit data mapping. Generated XML carries a reserved data-json-type marker wherever the type would otherwise be ambiguous, so its own arrays — including a list of one — empty objects, numbers, booleans and null values can make an honest trip back to JSON. Object keys beginning with @ become attributes, and #text becomes an element's text.
That convention does not make every XML document equivalent to JSON. Namespaces, DOCTYPE vocabularies and mixed content carry meaning the mapping cannot preserve, so those inputs stop with an explanation. Unmarked XML remains useful to inspect, but its leaf text is a string and a lone element cannot announce that it was meant as a one-item array.
Use this for data-shaped documents whose consumer accepts the mapping. For schema-governed SOAP, publishing, signed XML or industry feeds, use a mapper built for that vocabulary rather than assuming any generic conversion is lossless.
How it works
Toolvore parses and walks the document entirely in the browser. JSON to XML validates the chosen root and every key against a portable namespace-free XML name subset. An array becomes its named wrapper with data-json-type="array" and repeated <item> children; an object carries data-json-type="object"; numbers, booleans and null carry their corresponding type marker. That means empty arrays, one-item arrays, empty objects and scalar types generated here are restored on the return trip. Inside an object, @id becomes an id attribute and #text becomes element text. Attribute values may be strings, numbers or booleans, but null attributes are rejected because XML attributes cannot represent that distinction. XML to JSON maps attributes back to @name, keeps element text under #text when attributes or children require an object, and groups contiguous repeated sibling names into arrays. Unmarked leaf text stays a string. Namespace declarations or prefixes, DOCTYPEs, mixed text with child elements and interleaved repeated names are refused rather than flattened or reordered; comments are not data in this mapping and are omitted. Both directions enforce input, output, nesting-depth and node-count limits, and no document is uploaded.
Common use cases
- Checking what a legacy SOAP response actually contains
- Sketching a sample XML payload from the JSON in a ticket
- Turning an XML config fragment into JSON for a test fixture
- Reading a supplier feed that arrives in angle brackets
- Spotting which fields a partner's XML document carries
Frequently asked questions
How do you represent a JSON array in XML?+
An array keeps its JSON key as a wrapper, carries data-json-type="array", and contains one <item> child per value. An empty array is a marked self-closing wrapper. The marker is what distinguishes an empty array from an empty object and a one-item array from an ordinary element, so XML generated here restores the same array shape when converted back. A different system will only understand that meaning if it accepts this published convention.
What happens to XML attributes when you convert to JSON?+
Each attribute becomes a JSON key prefixed with @, so id="42" becomes @id: "42". Element text is kept under #text when an object is needed for attributes or children. XML attribute values always return as strings; JSON-to-XML accepts string, number or boolean attribute values, but a numeric attribute cannot announce that original JSON type on the way back. A null attribute is rejected instead of being turned into an empty string.
Why did my numbers and booleans come back as strings?+
Unmarked XML has no way to say that 42 is a JSON number rather than two text characters, so its leaf values deliberately remain strings. XML generated from JSON here marks numbers and booleans with data-json-type, and the reverse conversion restores those types; null, arrays and objects are marked for the same reason. Do not add those reserved markers casually to outside XML, because an invalid marker shape is rejected instead of guessed.
Is my data sent to a server when I convert it here?+
No. Both directions are ordinary functions called on the text already sitting in the box: JSON.parse and a recursive builder one way, the browser's built-in DOMParser and a walker the other. Nothing leaves the tab — no upload step, no server round trip, and nothing kept once you close it, since the input and result are component state and nothing else. That matters given what tends to get converted: API responses with customer records in them, payment feeds, config files listing internal hostnames. Switching direction empties both boxes on the spot as well.
Why does my XML fail to parse?+
Four causes cover nearly all of it. XML allows exactly one root element, so a fragment with two top-level tags is not a document and gets rejected. Tags are case-sensitive, so a closing tag capitalised differently closes nothing. A bare ampersand is illegal and has to be written as an entity, and the same goes for a less-than sign. And an entity HTML defines but XML does not — a non-breaking space is the usual culprit — fails unless the document declares it first. The message here is a flat invalid notice with no line number, so scanning for those four is quicker.
Why is the XML I generated rejected by another tool?+
First check whether the receiving system accepts this tool's data-json-type and <item> convention; valid XML is not automatically valid against someone else's schema. Generated element and attribute names are validated here: they must start with a letter or underscore, use only letters, numbers, dots, hyphens or underscores, and cannot begin with xml. Rename an invalid JSON key before converting. If the receiver merely requires an XML declaration, turn on the declaration checkbox.
Should a new API use JSON or XML?+
JSON, in most cases where the choice is genuinely free — it is smaller on the wire, it maps onto the data structures of every mainstream language, and browsers parse it natively. XML earns its place where documents rather than objects are the point: mixed content where text and markup interleave, validation in XSD, signatures over part of a document, and namespaces that let two vocabularies share a file without collision. In practice the choice is rarely free. Finance, government, healthcare, publishing and anything speaking SOAP settled on XML long ago.
What happens to XML namespaces in the conversion?+
The conversion stops. A namespace binds a name to a URI, and dropping that URI or keeping only the prefix would change the document's meaning. Any namespace declaration, namespace prefix or colon-qualified name is rejected with a direct explanation; use a schema-aware mapper that knows the expected URIs.
Used in these workflows
Related tools
JSON Diff
Compare JSON by ID, ignore noisy paths and export a strict JSON Patch when the comparison permits.
File Type Checker
Inspect recognized file signatures, extensions and browser MIME without opening or uploading the file.
JSON Formatter & Validator
Format, validate, and minify JSON with exact line errors, a searchable tree, and private processing.
Code Formatter
Format JavaScript, TypeScript, JSON, HTML or CSS with parser-aware indentation and downloads.