Practical guide
How to convert XML to JSON while preserving order
Ordinary XML text does not automatically establish JSON types. This guide covers reading an ordered tree and recovering data from the explicit typed profile without losing repeated elements.
Match the profile to the XML document
Paste one XML document with one root element. Choose tree mode for ordinary XML or the default typed profile for a <json version="1"> wrapper, then select “Process”. Well-formed XML need not match typed-profile grammar. Read <p>Cześć</p> as a tree, not as an implied business-data object.
The tool fetches no URLs, opens no external entities and does not validate XSD. An optional declaration must specify XML 1.0 and, if encoding is present, UTF-8. Namespaces, DTDs, comments and processing instructions are rejected rather than dropped. If they matter to the document, use another process suited to its complete contract.
Compare text with typed values
The first table row shows ordinary element p with an id attribute and mixed content. children contains text A, element b and text C in that order. Attribute "001" and text "B" remain strings. Repeated tags become successive objects in children, not duplicate properties overwriting each other in one object.
The second row uses Oblicznik profile v1. number, string and null elements explicitly identify types, so output distinguishes 1.00, "001" and null. Do not apply this decoding to similarly named tags without the correct wrapper and structure. Both profiles retain Polish characters as data rather than transliterating them to ASCII.
| Profile | XML | JSON |
|---|---|---|
tree | <p id="001">A<b>B</b>C</p> | {"name":"p","attributes":{"id":"001"},"children":["A",{"name":"b","attributes":{},"children":["B"]},"C"]} |
typed | <json version="1"><array><number>1.00</number><string>001</string><null/></array></json> | [1.00,"001",null] |
Preserve order without promising identical bytes
The tree has three fields: name, attributes and children. It retains mixed content, child order and text whitespace inside elements. It neither groups elements by name nor guesses that text true is boolean. This representation helps inspect structure but does not replace a domain model whose types are established by the application.
CDATA becomes text and & becomes an & character. Entity, declaration and empty-tag spelling are not reproduced byte for byte. XML normalizes some line endings and attribute whitespace; comparisons must account for parsed content rather than only the original file. Do not use this reserialization to verify signatures or document identity.
Decode the typed profile and check the receiver
A json root with version="1" contains exactly one value. Objects use member with a name attribute; arrays contain value elements in order. Unknown elements, extra attributes, duplicate names and invalid content cause errors. Stray container text is not ignored: only whitespace between structural elements is allowed.
Numbers retain exact tokens, including 9007199254740993, -0 and 1.00. Copying does not convert them through JavaScript Number, but a receiver might do so later and lose precision. Check the destination library’s numeric model. The profile reconstructs JSON values, not arbitrary XML; it adds no missing members, converts no string codes and infers no date types.
Handle rejection without deleting important content
Input and output allow 50,000 UTF-16 units each. The XML parser allows 10,000 nodes and 96 element levels; tree mode adds a 32-element-level cap and typed mode a 32-JSON-container-level cap. These are tool limits, not a definition of valid XML. A large document can be well-formed yet too large for this form.
Mismatched closing tags, duplicate attributes, forbidden characters, unknown entities or namespaces produce a message rather than partial output. Do not remove DTDs or prefixes from a real document merely to make the form accept it: meaning can change. Use a small sample without those constructs or a parser and validator appropriate for the receiver’s full specification.
Privacy and handing off output
Use short synthetic examples without customer data, passwords or API keys. Input and output stay in browser memory: the tool does not send them to analytics, put them in the page URL or keep history in localStorage or sessionStorage. Opening the page still connects your device to hosting. Browser extensions and other software on your device can have their own access to content.
Copying requires a separate click. Editing a field clears old output; process again after each change. “Clear” resets the form and options but cannot remove earlier clipboard copies, downloaded files or printouts. To report a problem, give the chosen mode, a small anonymized example and expected output. Before handing output off, check encoding and how the receiving application reads it.
Frequently asked questions
Will text true become boolean?
Not in tree mode: it stays text. A boolean is decoded only from a valid typed profile.
Will CDATA return in the same spelling?
No. It becomes text content; reserialization does not retain CDATA or entity spelling.
Do you validate XSD and resolve external entities?
No. The tool checks syntax and the profile. DTDs and external entities are unsupported.
Does reset remove copied data?
No. Reset clears the form and output, but earlier clipboard copies, files and printouts need separate removal.
Sources and scope
Examples are synthetic. Profiles and limits describe this site, not entire standards. Output does not establish API, XSD or business-rule compliance. Check it in the destination system before use.
Tools covered by this guide
JSON Schema validator
Check JSON data against a declared 2020-12 schema profile without network references or data mutation.
Sample JSON generator
Create one deterministic sample from a bounded schema and check it before returning output.
JSON to XML converter
Write JSON in a declared typed profile or reconstruct elements from an XML tree without guessing types.
XML to JSON converter
Read the typed profile or ordinary XML as a tree retaining attributes, text and child order.