Skip to content
Simple Tools

Practical guide

How to convert JSON to XML without guessing types

JSON and XML have no single universal mapping. This guide helps choose an explicit profile instead of guessing how a receiver interprets keys, types and repeated elements.

Simple Tools editorial teamReviewed: 2 October 2026

Choose the mapping first

Paste one valid JSON document, choose a profile and select “Process”. The default Oblicznik typed profile v1 preserves JSON type distinctions in a project format. Tree mode accepts a specific description of an XML element, not an arbitrary business object. Do not expect automatic adaptation to a government service, accounting system or external API.

Before copying output, establish the receiver’s expected root, attributes, ordering and requirements. The typed profile is not an API standard or XSD schema. Tree mode describes ordinary namespace-free elements. If the destination contract requires namespaces, special declarations or particular XSD rules, these tools cannot prepare a complete document for that integration.

Compare both profiles with a small sample

The first table row converts an ordinary JSON object into a <json version="1"> wrapper with an object element. Each member has a name attribute and one value element. This means keys with spaces and empty names need not become XML tag names. The chosen profile is part of the agreement with the receiver.

The second row describes element p, attribute id and text Cześć through name, attributes and children. Attributes have string values; children is an ordered array of strings or nested elements. Code 001 stays text. Here JSON describes an XML tree rather than exporting arbitrary data with guessed element names.

Different inputs for different profiles
ProfileJSONXML
typed{"city":"Łódź","code":"001"}<json version="1"><object><member name="city"><string>Łódź</string></member><member name="code"><string>001</string></member></object></json>
tree{"name":"p","attributes":{"id":"001"},"children":["Cześć"]}<p id="001">Cześć</p>

Preserve types in Oblicznik profile v1

The typed profile uses object, array, string, number, boolean and null. Empty objects and arrays stay distinct, and null is not an empty string. Array order is retained. Number tokens such as 1.00, -0 and 9007199254740993 do not pass through binary JavaScript Number, so the reverse converter can recover their exact spelling.

Reversibility covers values and numeric tokens in this profile, not original JSON spacing or escape spelling. A receiver can still lose precision by parsing a large number as Number. Do not change a textual identifier to number. Separately check string codes, null, false and empty arrays in the destination parser.

Describe attributes and mixed content as a tree

Each element object has exactly name, attributes and children. name must be a valid XML name without a namespace prefix; attributes maps names to string values. children can alternate strings and elements, such as ["A", {"name":"b","attributes":{},"children":["B"]}, "C"]. That order produces A<b>B</b>C without grouping repeated names.

Special characters are escaped as XML text; a <script> string does not become executable HTML. Do not manually put &amp; instead of & in JSON unless the intended text really is &amp;. Comments, processing instructions and namespaces have no representation in this supported tree. Do not add fields beyond the three required names.

Recognize character and size errors

Input and output each allow 50,000 UTF-16 units. JSON permits 10,000 values, the typed profile 32 container levels and tree mode 32 element levels. XML must fit supported XML 1.0. Not every JSON character is allowed in XML: a string containing NUL causes an error instead of silent removal.

Fix comments, duplicate keys and invalid Unicode before conversion. Expanded XML can exceed its limit despite shorter JSON because wrappers and escapes add characters. Use a smaller representative sample. After saving, check UTF-8 encoding and the receiver’s structural requirements. This converter neither validates XSD nor signs documents.

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

Does output suit every XML API?

No. The typed profile is a project format and tree mode excludes namespaces. Check the receiver’s contract.

Will 1.00 become 1?

The typed profile retains token 1.00. A receiver can still change spelling or precision when parsing.

Can I convert text containing NUL?

Not to XML 1.0. The tool reports a forbidden character rather than silently removing it.

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

Generator

JSON Schema validator

Check JSON data against a declared 2020-12 schema profile without network references or data mutation.

Generator

Sample JSON generator

Create one deterministic sample from a bounded schema and check it before returning output.

Generator

JSON to XML converter

Write JSON in a declared typed profile or reconstruct elements from an XML tree without guessing types.

Generator

XML to JSON converter

Read the typed profile or ordinary XML as a tree retaining attributes, text and child order.