AnyTool
Your files never leave your device. All processing happens locally in your browser.

How do I convert JSON to XML in the browser without uploading the file?

Open the JSON to XML Converter, then paste your JSON, drop in a .json / .txt file, or fetch a CORS-enabled URL — and it converts to XML live as you type, entirely in your browser. JSON keys become XML elements, keys that start with a chosen prefix (@ by default, or _ or $) become attributes, a #text key supplies an element’s text alongside its attributes, and a #cdata key emits a <![CDATA[…]]> block. JSON arrays repeat the parent tag — a list under “item” becomes several <item> elements — and a top-level array is wrapped in a configurable root and item element, while null and undefined emit self-closing tags. Six one-click presets set sensible options for common XML dialects: a generic root, RSS 2.0 feeds, SOAP envelopes, Android strings.xml resources, a Maven POM, and a Google sitemap.xml. You can switch the attribute prefix, toggle pretty-printing and the <?xml?> declaration, choose 2-space, 4-space or tab indentation, rename the root and array-item elements, change the text key (#text, _text or $t), and auto-wrap any string containing < or & in CDATA. A live preview updates as you type, a round-trip check flags whether the XML converts cleanly back to your JSON, and you can copy the result or download it as a .xml file. Everything runs on your device, so private data never leaves your machine (inputs up to 25 MB).

  • JSON keys become elements; keys prefixed with @ (or _ / $) become attributes; #text supplies text and #cdata emits a CDATA block
  • Arrays repeat the parent tag (<item><item>…) and a top-level array is wrapped in a configurable root / item element
  • Six presets — Generic, RSS 2.0, SOAP, Android strings.xml, Maven POM and sitemap.xml — plus a live preview and round-trip check
  • Options: attribute prefix, pretty-print, <?xml?> declaration, 2 / 4 / tab indent, custom root and item names, text key, and auto-CDATA
  • Copy or download .xml — 100% client-side, no upload, inputs up to 25 MB

What is

JSON to XML Converter

A JSON to XML converter transforms JSON — the lightweight, nested format used by web APIs and JavaScript — into XML, the tag-based markup still required by SOAP web services, RSS and Atom feeds, Android resource files, Maven build descriptors, sitemaps and many enterprise and legacy systems. The core challenge is that the two models do not line up one-to-one: JSON has objects, arrays, strings, numbers, booleans and null, whereas XML has elements, attributes, text nodes, CDATA sections and namespaces, and XML has no native array or number type. A converter therefore needs conventions to bridge the gap. The widely used approach — and the one this tool follows — maps each JSON key to an element, marks attributes with a prefix on the key (commonly @, so “@id” becomes id=“…”), uses a reserved #text key for the text of an element that also has attributes, uses a #cdata key for a CDATA section, and represents a repeated element as a JSON array whose items all share the parent key. Because a top-level JSON array has no obvious single root, the converter wraps it in a named root element with a named item element for each entry, and null values become empty self-closing tags. This converter is 100% client-side: it parses the JSON and serialises the XML in your browser with no upload, offers presets for common dialects (RSS, SOAP, Android strings, Maven POM, sitemap), lets you control the attribute prefix, indentation, XML declaration, root and item names and CDATA handling, and runs a round-trip check that re-parses the XML to warn when a construct will not convert back cleanly. Its honest limits: XML namespaces must be written as ordinary prefixed keys or xmlns attributes since JSON has no namespace concept, comments and processing instructions are not generated, everything is text so numeric and boolean types are not preserved as types, and very large inputs are bounded by browser memory (a 25 MB cap).

File Tools

Related terms

JSONXMLattributesCDATAnamespacesRSSSOAPsitemap.xmlMaven POMAndroid strings.xmlXML declarationelementtext nodeXML to JSONround-trip

Frequently Asked Questions

No. The JSON is parsed and the XML is built entirely in your browser — there is no upload, server or account, so your data never leaves your device.

Nothing is uploaded. When you paste text or open a file the converter reads it locally with the browser’s File API, parses it into memory, and serialises the XML on your device in JavaScript. There is no server, API, database or tracking in the processing path, so an API response, config file or any other sensitive data stays on your machine. The tool works offline once cached, and closing the tab discards everything. The one case where data touches the network is if you paste a remote URL for the tool to fetch — and even then the response is downloaded straight into your browser and never sent anywhere else. The only optional network use anywhere on the site is consent-gated advertising, which never sees your file.

Keys prefixed with @ become XML attributes, a #text key becomes an element’s text, #cdata becomes a CDATA section, and a JSON array repeats the parent element tag.

The converter uses simple, well-known conventions. Every ordinary JSON key becomes an element, and its value becomes that element’s content. A key that starts with the attribute prefix — @ by default, switchable to _ or $ — becomes an attribute on the enclosing element, so {“book”:{“@id”:“7”}} yields <book id=“7”/>. When an element needs both attributes and text you put the text under the reserved #text key, and a #cdata key emits a <![CDATA[…]]> section for content you do not want escaped. A JSON array repeats the parent tag once per item, so several objects under “item” become several <item> elements; a top-level array, which has no single root, is wrapped in a configurable root element with a configurable item element per entry. null and undefined become empty self-closing tags.

Yes — six one-click presets set the right options for a generic root, RSS 2.0 feeds, SOAP envelopes, Android strings.xml, a Maven POM and a Google sitemap.xml.

Because different XML dialects expect different root names and conventions, the tool ships six presets that load a matching sample and configure the options for you. Generic produces a standard <root> with @ attributes; RSS 2.0 builds a podcast or news feed with a channel and repeated items; SOAP wraps a request in a soap:Envelope with the usual namespace attribute; Android strings.xml emits a <resources> block of localisation strings; Maven POM writes a Java project descriptor; and Sitemap generates a <urlset> of URLs for Google. Namespaces are handled as ordinary keys — write an xmlns declaration as an @xmlns attribute and prefixed element names like soap:Body as the key itself — because JSON has no built-in namespace concept.

The round-trip check re-parses the generated XML back to JSON and flags “Lossy” when a construct will not convert cleanly both ways; XML types, comments and true namespaces are the main limits.

After each conversion the tool converts the XML it produced back into JSON and compares it with your input, showing “Round-trip OK” when the two match and a “Lossy” warning when they do not — usually because of CDATA, mixed content or namespace edge cases that cannot be represented identically in both directions. The honest limits follow from XML itself: everything between tags is text, so numbers and booleans are not preserved as JSON types on the way back; comments and processing instructions are not generated; and XML namespaces have no native JSON equivalent, so they must be written as prefixed keys or xmlns attributes rather than inferred. Inputs are held in browser memory under a 25 MB cap, and loading a remote URL only works when that server sends permissive CORS headers.

Detailed Explanation

How It Works

Converting JSON to XML in Your Browser

The JSON to XML Converter turns JSON — the nested format used by web APIs and JavaScript — into well-formed XML without ever uploading it. Paste JSON, drop in a .json or .txt file, or fetch a CORS-enabled URL, and it converts live as you type. It uses simple conventions to bridge the two models: each JSON key becomes an element, a key prefixed with @ (switchable to _ or $) becomes an attribute, a #text key supplies the text of an element that also has attributes, a #cdata key emits a CDATA section, a JSON array repeats the parent element tag, and null becomes a self-closing tag. A top-level array — which has no single root — is wrapped in a configurable root element with a configurable item element per entry. Everything runs locally in JavaScript, so API responses and configuration data never leave the device.

  • Keys become elements; @-prefixed keys become attributes; #text supplies text; #cdata emits a CDATA section
  • Arrays repeat the parent tag; a top-level array is wrapped in a configurable root and item element; null is self-closing
  • Live conversion from pasted text, a .json / .txt file, or a CORS-enabled URL
  • 100% client-side — nothing is uploaded to any server
Use Cases

Feeding XML-Only Systems from JSON

JSON is what modern APIs emit, but many systems still consume XML, so this converter bridges the gap. Six one-click presets target common dialects: Generic produces a standard root with @ attributes; RSS 2.0 builds a podcast or news feed with a channel and repeated items; SOAP wraps a payload in a soap:Envelope with its namespace attribute; Android strings.xml emits a resources block of localisation strings; Maven POM writes a Java project descriptor; and Sitemap generates a urlset for Google. Each preset loads a matching sample and sets the attribute prefix, root name and item name for you, so a REST response becomes a valid feed, envelope or resource file in one click. When you need the reverse direction, the companion XML to JSON Converter flips the workflow back the other way.

  • Six presets: Generic, RSS 2.0, SOAP, Android strings.xml, Maven POM, sitemap.xml
  • Turns REST / API responses into feeds, SOAP envelopes, Android resources or sitemaps
  • Each preset loads a sample and sets the attribute prefix, root and item names
  • A companion XML to JSON tool performs the reverse conversion
Technical Details

Attribute Prefixes, CDATA and Serialisation

Conversion runs in a debounced client-side effect on every keystroke: the input is JSON.parse-d and walked recursively to build XML. A key whose name starts with the active attribute prefix (@ by default, or _ or $) is emitted as an attribute on the enclosing element rather than a child element; the reserved #text key supplies mixed text content; a #cdata key emits a <![CDATA[…]]> section; and an optional auto-CDATA mode wraps any string containing < or & in CDATA so it stays well-formed without manual escaping. Arrays are serialised by repeating the parent tag once per item, and a top-level array is wrapped in the configured root and item elements. Output options include pretty-printing with 2-space, 4-space or tab indentation, an optional <?xml?> declaration, a custom root and array-item name, and a choice of text key (#text, _text or $t). After each run the tool performs a round-trip check — it converts the generated XML back to JSON and compares it with the input — and reports byte-size stats for both sides; the whole input is held and processed in memory under a 25 MB cap.

  • Debounced live conversion: JSON.parse then a recursive walk to XML
  • @-prefixed keys become attributes; #text is mixed text; #cdata and auto-CDATA emit CDATA sections
  • Pretty-print with 2 / 4 / tab indent, optional XML declaration, custom root / item names, text key #text / _text / $t
  • Round-trip check re-parses the XML back to JSON; input processed in memory (25 MB cap)
Limitations

Honest Limitations

The converter is honest about where the JSON and XML models diverge. XML namespaces have no native JSON equivalent, so they are not inferred: you write an xmlns declaration as an @xmlns attribute and a prefixed element name such as soap:Body as the key itself. XML is text between tags, so JSON numbers and booleans are serialised as strings and are not preserved as types on a round-trip, which is why the round-trip check may report “Lossy” for CDATA, mixed content or namespace edge cases. Comments and processing instructions are not generated. Everything is held in browser memory, so size is bounded by a 25 MB input cap, and very large inputs use more RAM and can slow a low-memory device. Loading from a remote URL only works when that server sends permissive CORS headers, and the fetch fails with a clear message otherwise rather than silently.

  • Namespaces are not inferred — write them as @xmlns attributes or prefixed keys
  • XML is text, so numbers and booleans are not preserved as types (round-trip may be flagged Lossy)
  • Comments and processing instructions are not generated
  • Bounded by browser memory (25 MB cap); remote-URL loading needs permissive CORS or it fails clearly
Privacy & Security

Privacy: Your Data Stays on Your Device

JSON payloads often hold exactly the data you should not upload — API responses, customer and order records, tokens in config files, analytics events — and this converter is built so they never leave your machine. Input is read with the browser’s File API, parsed into memory and serialised to XML locally in JavaScript, with no server, upload, database, logging, API or CDN anywhere in the processing path. The tool works offline once cached, and closing the tab discards everything. The only moment anything touches the network is if you explicitly paste a remote URL for the tool to fetch, and even then the response is downloaded straight into your browser and sent nowhere else. The only optional network use anywhere on the site is consent-gated advertising, which never sees your file or its contents.

  • Read, parsed and serialised entirely in the browser
  • No server, upload, database, API or CDN in the processing path
  • Works offline once cached; closing the tab discards everything
  • Only optional network use is consent-gated ads, which never see your file
JSON to XML Converter — conventions, options and limits
CapabilitySupportNotes
AttributesKeys prefixed with @ (or _ / $)“@id”: “7” becomes id=“7” on the enclosing element
Text & CDATA#text for mixed text, #cdata for CDATAOptional auto-CDATA wraps strings containing < or & so they stay well-formed
ArraysRepeat the parent element tagA top-level array is wrapped in a configurable root and item element
PresetsGeneric, RSS 2.0, SOAP, Android strings.xml, Maven POM, sitemap.xmlEach loads a sample and sets the attribute prefix, root and item names
Output optionsPretty-print, <?xml?> declaration, 2 / 4 / tab indent, custom root / item namesText key #text / _text / $t; a round-trip check flags lossy constructs
Limits & scaleNamespaces manual, types not preserved, up to 25 MBComments not generated; remote-URL loading needs permissive CORS; 100% client-side

The converter maps each JSON key to an element, marks attributes with an @ (or _ / $) prefix, uses #text and #cdata for text and CDATA, repeats the parent tag for arrays, and wraps a top-level array in a configurable root and item element. Six presets cover common XML dialects, output options control indentation, the XML declaration and element names, and a round-trip check flags constructs that will not convert back cleanly. It is bounded by a 25 MB browser-memory cap and remote-URL loading needs permissive CORS. Everything runs in the browser; nothing is uploaded.