JSON to XML Converter

Runs 100% in your browser

Convert JSON to well-formed, syntax-highlighted XML in your browser — live mode, valid/invalid badge, 5 sample presets, @attribute hints, CDATA mode, DOMParser validation, 7 stats, and zero uploads.

Waiting 0 bytes — 0 lines

Use @id or _attributes:{} for XML attributes — _text for mixed content — Ctrl+Enter to convert

Waiting for valid JSON
Your highlighted XML output will appear here.
Input bytes0
Output bytes0
Elements0
Attributes0
Arrays0
Max depth0
XML valid

JSON ? XML mapping reference

@id ? XML attribute — _attributes:{id:"x"} ? XML attribute group — _text ? element text content — Array items ? repeated sibling elements (or wrapper+item with wrapper mode) — null ? self-closing or empty element — CDATA wrapping preserves < > & in text values for legacy parsers. Review the generated XML against your receiving system's schema before production use.

SESSION HISTORY

Recent conversions

No conversions in this session yet.
Private by architecture

JSON parsing, XML serialization, DOMParser validation, and syntax highlighting run entirely in your browser. No JSON is uploaded, sent to an API, stored in localStorage, or included in analytics. Disconnect your internet after page load and the tool works identically. Your API keys, SOAP credentials, and configuration secrets stay on your machine.

Frequently asked questions

A JSON to XML converter serializes JSON objects, arrays, strings, numbers, booleans, and null values into well-formed XML markup. Because JSON and XML model data differently — JSON has no attributes, no mixed content, no document declarations, and no namespaces — a good converter makes every schema-sensitive choice visible rather than silently picking one mapping for all use cases. ToolsSonic validates the JSON first, then serializes it locally in your browser with no upload.

Paste a JSON object or array into the input field, or click "Open JSON file" to load a local .json file. The live mode converts automatically as you type — a Valid JSON badge confirms your input is parseable. Adjust the XML root name, attribute mode, array strategy, null handling, indent, CDATA, and declaration controls, then click "Copy XML" or "Download .xml". Everything runs in your browser with no server involved.

When the Live checkbox is checked, the converter re-runs automatically 380 milliseconds after you stop typing. A Valid JSON ✓ or Invalid JSON badge in the input panel updates in real time as well. You can uncheck Live and press the Convert to XML button or use the Ctrl+Enter keyboard shortcut for manual control. Live mode is useful for iterative editing; manual mode avoids accidental conversions during pasting large documents.

The default root element is root. Replace it with any valid XML name such as catalog, envelope, items, or response. Many integration and WSDL-based APIs require a specific root element name — the converter validates your input against the XML name pattern and falls back to root if it is invalid. The root element wraps the entire JSON document as one XML element.

Arrays have two conversion strategies. Repeat element names (default) produces consecutive sibling elements sharing the same tag name, which is what most REST-to-XML, JSON-to-RSS, and JSON-to-Atom conversions expect. Wrapper mode wraps the array in a named parent element containing repeated child elements whose name is configurable (default: item). Choose the strategy required by the receiving XSD, WSDL, or API contract.

Prefix a JSON key with @ (such as @id or @version) and the converter maps it to an XML attribute on the parent element. Alternatively, group attributes inside an _attributes object: {"_attributes":{"id":"1","type":"book"}}. Both styles can coexist. Choose "All as child elements" in the Attributes control if your JSON contains no attribute hints and you want every value as a child element.

CDATA (Character Data) sections wrap text content that contains the XML-sensitive characters &, <, or > in a <![CDATA[...]]> block instead of escaping them with &amp;, &lt;, or &gt;. Enable CDATA wrapping when the receiving parser is a legacy SAX parser, an older SOAP processor, an Android XML resource reader, or any system that prefers CDATA over entity references. Standard modern XML parsers handle both forms identically, so entity escaping is the safer default for new integrations.

Yes. After serialization, ToolsSonic passes the generated XML string through the browser's native DOMParser with the application/xml MIME type. If the parser finds a well-formedness error — malformed tags, duplicate attributes, or unresolved entity references from unusual inputs — the stats bar shows a ⚠ Not well-formed indicator and the error panel shows the diagnostic. This catches edge cases that simple string serializers can miss.

The input panel shows a live status badge that reads "Valid JSON ✓" (green) when the current input text is parseable by JSON.parse, "Invalid JSON" (red) when it is not, and "Waiting" (grey) when the field is empty. This badge updates every time you type, so you know whether a conversion attempt will succeed before clicking the Convert button.

The preset selector in the toolbar loads five ready-made JSON examples covering the most common conversion scenarios: Simple object (flat key-value pairs with null and boolean), Nested arrays (recursive book library with tag arrays), @Attributes & _text (catalog items with @id attributes and mixed price elements), RSS feed (a two-item RSS 2.0 channel structure), and SOAP envelope (a SOAP 1.1 envelope with soap: namespace prefixes via _attributes). Each preset demonstrates a different feature and loads immediately without clearing the controls.

A _text key inside a JSON object is treated as the text content of that element. For example {"@currency":"USD","_text":"19.99"} produces <price currency="USD">19.99</price>. This allows you to express elements that have both attributes and text content — the most common mixed-content pattern in XML. Elements with only child elements and no _text key produce only child elements. Review mixed content before SOAP or XHTML consumption because whitespace and ordering can matter.

Yes. Text content and attribute values escape all five XML-sensitive characters: ampersand (&amp;), less-than (&lt;), greater-than (&gt;), double quote (&quot;), and apostrophe (&apos;). Inside attribute values, carriage-return (&#13;), newline (&#10;), and tab (&#9;) are also escaped because some XML parsers normalize unescaped whitespace in attribute values. Many simpler online converters miss apostrophes and attribute line characters — this can cause well-formedness failures in strict XML parsers without obvious errors at first inspection.

Yes. The serializer is fully recursive. Nested objects become child elements. Arrays of objects produce repeated or wrapped elements depending on your Arrays control. Arrays nested inside objects work the same way at every depth level. The stats bar reports maximum nesting depth so you can see how deep the generated XML tree goes.

JSON null can be serialized as a self-closing element (<price />) or as an empty element pair (<price></price>). Self-closing is compact and common in modern REST-to-XML conversions. Empty pairs are required by some strict XSD schemas and XML-based serializers that distinguish between a null value and a missing element. Choose the convention required by the target system.

Yes. Load the SOAP envelope preset or the RSS feed preset to see exactly how to structure your JSON. For SOAP, add a namespace prefix to the key and place the namespace URI declaration inside _attributes: {"soap:Envelope":{"_attributes":{"xmlns:soap":"http://schemas.xmlsoap.org/soap/envelope/"},"soap:Body":{...}}}. For RSS, structure the channel object with an item array. The converter handles colon-qualified names like soap:Body as valid XML element names.

Press Ctrl+Enter (or Cmd+Enter on Mac) while the JSON input is focused to trigger an immediate conversion, regardless of whether Live mode is on. This is the fastest way to convert after pasting a large JSON document. The shortcut is shown in the Local only badge in the hero and in the input help text.

Input bytes is the UTF-8 byte count of the JSON source. Output bytes is the UTF-8 byte count of the generated XML. Elements counts every XML element produced. Attributes counts every XML attribute produced. Arrays counts the number of JSON arrays serialized. Max depth is the deepest nesting level in the generated XML tree. XML valid shows ✓ Valid when DOMParser confirms well-formedness, or ⚠ Not well-formed when a structural issue is detected.

Yes. The "Copy XML" button copies the XML as currently formatted (using your selected indentation). The "Copy compact" button re-serializes the same JSON using compact (no-whitespace) output and copies it to the clipboard without changing your indentation setting. This is useful when you need both a readable copy for review and a compact payload for transmission without switching the indent control back and forth.

The converter stops before producing any XML, clears the output panel, disables the Copy and Download buttons, and shows the JSON.parse error message in the error panel. Common causes include a missing comma between properties, a trailing comma before } or ], single quotes instead of double quotes, an unquoted key, a JavaScript comment, or unmatched brackets. Use the JSON Validator tool for precise line-and-column diagnostics and targeted repair hints.

Yes. ToolsSonic requires no account, no email, no login, and no subscription. The tool is fully functional from the first page load with no rate limit. All processing runs in your browser — JSON parsing and XML serialization use browser-native APIs, DOMParser validates the output locally, and syntax highlighting applies in-memory without any remote call.

Yes. JSON parsing, XML serialization, DOMParser output validation, and XML syntax highlighting all run in browser memory only. ToolsSonic does not upload your JSON, call a remote conversion API, store input in localStorage or sessionStorage, or include your data in analytics. The session history at the bottom stores only non-content metadata — file name and input byte count — never the actual JSON text or XML output. Disconnect your internet after the page loads and the tool works identically.

What is JSON to XML Converter?

What Is a JSON to XML Converter?

A JSON to XML converter serializes JSON objects, arrays, strings, numbers, booleans, and null values into well-formed XML markup. Because JSON and XML model data differently — JSON has no attributes, no mixed content, no document declarations, and no namespaces — a professional converter makes every schema-sensitive decision visible rather than silently choosing one mapping. ToolsSonic validates the JSON first, highlights the XML output with color-coded syntax, and validates the result through the browser's DOMParser — all without uploading a single byte.

How ToolsSonic Converts JSON to XML

Live auto-convert with a valid/invalid badge. The converter runs automatically as you type. A color-coded "Valid JSON ✓" (green) or "Invalid JSON" (red) badge updates in real time in the input panel, so you know the moment your JSON becomes parseable. Press Ctrl+Enter or Cmd+Enter to force a manual conversion at any time.

Root element control. Every XML document must have exactly one root element, and enterprise or WSDL-based APIs frequently require a specific name such as catalog, envelope, or GetUserRequest. The default is root, but you can replace it with any valid XML name. The serializer validates the name against the XML Name production rule and falls back to root if invalid.

Attribute hints. Use @id prefix notation or group attributes inside an _attributes object to map JSON properties to XML attributes on their parent element. Choose the elements-only mode if your JSON has no attribute hints. The _text key produces element text content alongside attributes, enabling full mixed-content patterns such as <price currency="USD">19.99</price>.

Array modes. Repeat element names (default) produces consecutive sibling elements sharing the same tag — the standard for REST-to-XML, JSON-to-RSS, and JSON-to-Atom pipelines. Wrapper mode wraps the array in a named parent element containing repeated item children, with a configurable item element name. Choose the strategy expected by the receiving XSD or WSDL.

CDATA wrapping. Enable CDATA mode to wrap text values containing &, <, or > in <![CDATA[...]]> sections instead of entity-escaping them. CDATA is preferred by legacy SAX parsers, older SOAP processors, Android XML resource readers, and some build-tool XML consumers. Modern parsers handle both forms identically.

Five XML escaping rules. Text content and attribute values escape all five XML-sensitive characters: &amp;, &lt;, &gt;, &quot;, and &apos;. Attribute values additionally escape carriage-return, newline, and tab as &#13;, &#10;, and &#9;, because some XML parsers normalize unescaped whitespace in attributes. Many simpler online converters miss apostrophes and attribute line characters, producing malformed XML that passes visual inspection but breaks strict parsers.

DOMParser output validation. After serialization, the generated XML is passed through the browser's native DOMParser. A "✓ Valid" indicator in the stats bar confirms well-formedness. An "⚠ Not well-formed" indicator with an error panel message catches structural edge cases that string-based serializers can miss.

XML syntax highlighting. The output panel renders XML with color-coded token classes: XML declarations in violet, element names in blue, attribute names in teal, attribute values in green, CDATA sections in amber, and comments in grey — both in light and dark mode. This makes deeply nested XML structures readable at a glance without copying to an external editor.

Seven stats. The stats bar shows input bytes, output bytes, element count, attribute count, array count, maximum nesting depth, and XML validity — giving you a full picture of the conversion in one row.

Common use cases

  • Converting a REST API JSON response into XML for a legacy SOAP or WSDL-based enterprise endpoint
  • Building an RSS 2.0 or Atom feed from a JSON content object with properly repeated item elements
  • Mapping @id, @version, and _attributes hints into proper XML attributes for schema-driven APIs
  • Choosing a required XML root element name for an integration, WSDL contract, or XSD definition
  • Generating Spring, Maven, Ant, or configuration XML from a JSON settings or properties object
  • Creating a SOAP envelope from a JSON payload using _attributes namespace declarations
  • Converting JSON locale objects into Android strings.xml format with CDATA-wrapped special characters
  • Validating that the generated XML is well-formed before sending it to an enterprise or government API
  • Opening a local .json file for conversion without uploading it to any server
  • Using the compact copy for transport payloads while keeping the formatted view for review

Why use ToolsSonic's JSON to XML Converter?

ToolsSonic's JSON to XML Converter is the most complete browser-based JSON-to-XML tool available. It adds live auto-convert, a real-time valid/invalid JSON badge, XML syntax highlighting with 7 token classes, DOMParser output validation, CDATA wrapping mode, 5 sample presets (simple, nested arrays, @attributes, RSS feed, SOAP envelope), a Copy compact button alongside Copy XML, Ctrl+Enter keyboard shortcut, 7-stat bar including XML validity, a visual mapping legend, and full dark mode — all in browser memory with no upload, no account, and no rate limit. The tool explains that JSON cannot uniquely describe every XML schema, making limitations explicit so developers understand what to review before production use.

How to Convert JSON to XML — Step by Step

Step 1 — Paste or load JSON. Click the Paste button to read from your clipboard, use the Open JSON file label to load a local .json file, or choose a preset from the "Load sample…" dropdown. The Valid JSON ✓ badge turns green as soon as the input is parseable.

Step 2 — Set the XML root name. In the controls row below the I/O panels, enter the root element name required by your API, XSD, or WSDL (for example: catalog, envelope, or GetOrderResponse). Leave it as root if the receiving system does not require a specific name.

Step 3 — Choose attribute and array modes. Select "@key and _attributes" if your JSON uses @-prefixed keys or _attributes objects. Select "All as child elements" for pure element-based XML. For arrays, choose "Repeat element names" for sibling-element output or "Wrapper + item elements" for wrapped-array output.

Step 4 — Toggle CDATA and declaration. Check "CDATA wrapping" if the consuming parser prefers CDATA sections for text containing special characters. Keep "XML declaration" checked to include the standard UTF-8 XML prolog.

Step 5 — Convert and validate. The stats bar shows element count, attribute count, array count, max depth, and the XML validity result. If "⚠ Not well-formed" appears, check the error panel and adjust your JSON structure or root name.

Step 6 — Copy or download. Click "Copy XML" for the formatted output, "Copy compact" for a whitespace-free payload, or "Download .xml" to save the file locally. Press Ctrl+Enter at any time to re-run the conversion.

JSON to XML Mapping Reference

Understanding the JSON-to-XML mapping lets you structure your JSON to produce exactly the XML your receiving system expects.

JSON object → XML element with children. An object property "book": {"title": "Clean Code"} produces <book><title>Clean Code</title></book>.

JSON array → repeated sibling elements. An array "item": ["a","b","c"] produces <item>a</item><item>b</item><item>c</item> in repeat mode, or <items><item>a</item><item>b</item><item>c</item></items> in wrapper mode.

@key prefix → XML attribute. A key beginning with @ such as "@id": "42" produces an attribute on the containing element: <element id="42">.

_attributes object → attribute group. "_attributes": {"id":"1","type":"book"} produces <element id="1" type="book">.

_text key → element text content. {"@currency":"USD","_text":"19.99"} produces <price currency="USD">19.99</price>.

JSON null → self-closing or empty element. Null values produce either <notes /> (self-closing) or <notes></notes> (empty pair) depending on the Null values control.

JSON boolean → text "true" or "false". JSON booleans are serialized as their string representation in XML text content.

JSON number → text content. Numbers are written as their decimal string form. Use _text if you need a number inside a mixed-content element with attributes.

SOAP namespace pattern. Use a colon in the object key ("soap:Envelope") and declare the namespace URI via _attributes: {"_attributes":{"xmlns:soap":"http://schemas.xmlsoap.org/soap/envelope/"}}. The converter treats the full colon-qualified name as a valid XML element name.

Why ToolsSonic Outranks Every JSON to XML Competitor

Most online JSON to XML tools — Code Beautify, FreeFormatter, ConvertJSON.com, Utilities-Online.info, and transform.tools — share the same basic limitation: static single-sample converters with no input validation feedback, no output highlighting, and no output validation. Here is how ToolsSonic addresses every gap.

Live mode. Competitors require a button click or form submission to re-convert. ToolsSonic converts 380 ms after you stop typing. Every control change — root name, array mode, CDATA, declaration — triggers an instant re-render with no interaction required.

Valid/Invalid JSON badge. No other free converter shows a real-time JSON validity indicator in the input panel. This single feature eliminates the most common frustration: typing into a tool and not knowing why the output is empty.

XML syntax highlighting. The output panel renders color-coded XML (declarations, element names, attributes, values, CDATA, comments) using a zero-dependency regex tokenizer. Competitors show plain monospace text. Highlighted output is dramatically easier to scan for structure and attribute placement.

DOMParser output validation. ToolsSonic verifies the generated XML is actually well-formed using the browser's own XML parser. The "✓ Valid" stat is a real structural guarantee, not just "the serializer ran without error."

CDATA wrapping. FreeFormatter supports CDATA; most other free converters do not. ToolsSonic adds it with a toggle that applies to all text values simultaneously — no manual editing required.

5 sample presets. Competitors offer one hardcoded example. ToolsSonic provides five: simple object, nested arrays, @attributes, RSS feed, and SOAP envelope — covering every common conversion pattern without users having to build test cases from scratch.

Copy formatted + Copy compact. Two copy actions let you get a human-readable copy for review and a whitespace-free payload for transmission without changing the indent setting.

Privacy. Unlike Code Beautify (URL loading traverses their server) and FreeFormatter (server-side conversion), ToolsSonic runs entirely in browser memory. The privacy guarantee is architectural, not a policy statement.

100% private — runs in your browser Instant — no server round-trip Free forever — no account needed