Convert JSON and XML Locally
Convert JSON to XML or XML to JSON in your browser. Work with attributes and repeated elements, and check what changes during conversion.
Tool workspace
Use @attributes for string attributes and #text for leaf text. Arrays become repeated elements. Names are ASCII; namespaces and mixed content are unsupported. Read the complete model explanation
Paste text or choose one local UTF-8 file. Press Convert to process it.
Ready for input.
Web Workers are unavailable. Conversion cannot run here; input stays local.
Errors and conversion notices
Some diagnostic details were omitted; the causal error is preserved.
Copy and download use the complete current output.
Model and supported subset
Use the single root property requires a JSON object with exactly one property: its name becomes the XML root. Wrap with a root name adds the chosen root around the content. A root array uses the item name; property arrays repeat their own names. Arrays must be nonempty and cannot be directly nested. @attributes is an object of string values; #text is a string allowed only without child elements, including empty or whitespace text. XML attributes return under @attributes and an attributed leaf includes #text. Contiguous same-name children become arrays; interleaved groups are rejected to preserve order. An empty XML leaf without attributes becomes an empty JSON string; a leaf with attributes keeps #text="" inside an object. Numbers and booleans lose type; null, empty objects and singleton arrays lose intent. XML 1.0 data subset: ASCII names of 1–64 characters, no xml prefix, namespaces, DTD or processing instructions. Only predefined entities and numeric references are decoded once. Comments, CDATA delimiters, declarations and presentation whitespace are omitted with notices. Leaf spaces are retained; XML line endings and literal attribute whitespace normalize. There is no automatic type inference or repair.
XML text and attributes stay strings, including 00123. The root is retained; JSON types are never inferred.
XML loses JSON types and single-item array intent. No universal round trip: null and an empty object can become the same empty element. XML → JSON keeps strings and the real root.
Limits
Input: 1,000,000 UTF-16 units / 2,000,000 UTF-8 bytes. File: 2,000,000 bytes. Depth JSON/XML: 100/40. Output: 2,000,000 UTF-16 units / 4,000,000 UTF-8 bytes.
Processing is local. Documents are not uploaded, logged or persisted.
Convert a catalog from JSON to XML
Paste JSON or load a local .json file, choose JSON → XML, then press Convert. In this example, the single root property becomes the XML element catalog. The two items become two item elements, and @attributes supplies their attributes.
{"catalog":{"@attributes":{"id":"00123"},"item":[{"@attributes":{"code":"a"},"#text":"uno & dos"},{"@attributes":{"code":"b"},"#text":"tres"}]}}
<catalog id="00123"><item code="a">uno & dos</item><item code="b">tres</item></catalog>
The default Use the single root property option needs an object with one ordinary property. For other inputs, choose Wrap with a root name to add a surrounding element, initially root. For a root array, the item name defaults to item; it does not rename arrays inside properties. You can choose compact output or indentation of 2 or 4 spaces.
Use @attributes for an object of string-valued attributes. Use #text for the text of an element that has no child elements. Its value must be a string, even if it is empty. Arrays repeat the property’s element name. Empty arrays and arrays nested directly inside arrays are not supported.
Convert XML back to JSON
Choose XML → JSON, paste XML or open a .xml file, then convert. The XML root stays as a JSON property. Attributes appear under @attributes.
Text and attributes remain strings: 00123 keeps its leading zeros, and true does not become a boolean. An element without attributes or children becomes a string. An element with attributes and no children also has #text, including when its text is empty.
Consecutive elements with the same name become an array. Elements ordered as a/b/a are rejected because grouping the two a elements would change their order.
What a round trip can change
Check the notices before using the result. XML cannot preserve every distinction in the JSON:
| JSON input | After converting to XML and back |
|---|---|
| Number or boolean | A string containing its text |
null or {} |
An empty string |
| A one-item array | A value without the array wrapper |
An object containing only #text |
A string |
Number spellings such as 9007199254740993, 1.2300 and -0 are kept when writing XML, even though their JSON type is lost. Numbers outside the supported finite range are rejected.
An empty @attributes: {} is omitted with a notice; an empty attribute such as id="" is retained. A root array returns inside the XML root property, rather than as a root JSON array.
Supported XML
This tool converts XML 1.0 data with one root element. Names must contain 1–64 ASCII characters, start with a letter or underscore, and continue with letters, digits, underscores, hyphens or dots. Names starting with xml, namespace syntax and unsafe prototype-related names are rejected; keys are not renamed automatically.
Namespaces, DTD/DOCTYPE, ENTITY declarations, processing instructions and mixed text with child elements are unsupported. Closing tags must match, attributes must be distinct and JSON keys must not be duplicated.
The five predefined XML entities and valid numeric references are decoded once: &lt; becomes the text <. CDATA contributes its text; comments, CDATA delimiters and the XML declaration are omitted with notices. XML line endings are normalized to LF. Literal tabs and line breaks in attributes become spaces; numeric references retain those characters. Formatting spaces between children are omitted, while spaces in leaf text remain data.
Files, limits and downloads
Files must use UTF-8. One initial BOM is removed with a notice; a second is rejected. Copy and download include the full result, even when the preview stops at 50,000 UTF-16 units. A clipboard failure offers manual copying.
| Limit | Maximum |
|---|---|
| File / input encoded as UTF-8 | 2,000,000 bytes |
| Input length | 1,000,000 UTF-16 units |
| Output | 2,000,000 UTF-16 units / 4,000,000 bytes |
| JSON input depth / XML depth | 100 / 40 |
| Conversion time | 8 seconds |
Complex documents can hit processing limits before these maxima. Errors, cancellation or an exceeded limit produce no partial output.
Downloads are converted.xml or converted.json, in UTF-8 without BOM. XML has no declaration and ends with LF. JSON uses the chosen indentation without a final newline.
Conversion uses a local Worker and requires JavaScript. Documents are not uploaded or stored in the browser. After changing the input, mode or options, convert again to get a result you can export.