JSON to XML
A JSON to XML converter turns a JSON object or array into well-formed, indented XML. This one runs in your tab: keys become elements, @-prefixed keys become attributes, #text becomes element text, and an array repeats its tag once per item. Keys that are not valid XML names are made safe and reported. Nothing is uploaded or written to localStorage. It is not an XSD validator and not a SOAP client.
Updated
Paste or drop a .json file, set the root element name and the array item name, pick the attribute prefix and indent, then copy or download .xml. Text and attribute values are escaped (& < > "). Invalid JSON gets an honest in-page error instead of invented output.
This is the reverse of XML to JSON at /file-conversion/xml-to-json/ — the same @attr, #text, and repeated-tag conventions, so a document can round-trip. One canonical URL with a trailing slash and no /in/ prefix; India-first SAMPLE examples use city names and the same page works globally.
Paste JSON (object or array). Drop a .json file — it stays in this tab. @keys become attributes, #text becomes element text, arrays repeat the tag.
Optional .json drop. Read with FileReader in this tab — never uploaded.
XML output
How does the JSON to XML work?
1. Paste or drop JSON
Any valid JSON object or array works. Dropped .json files are read with FileReader in this tab — never uploaded.
2. Set root, item name, and attributes
A single top-level key becomes the root element; otherwise the JSON is wrapped in the root name you choose (default root). Items of a top-level array use the array item name (default item). Keys with the @ prefix (or - / _) become attributes.
3. Convert locally
Elements are written in this tab with XML escaping and your chosen indent (2 spaces, 4 spaces, tab, or minified). Keys that are not valid XML names are renamed (for example "first name" → first_name) and listed as notes.
4. Copy or download
Copy the XML or download .xml. Invalid JSON shows a short parse error and leaves the output empty. Closing the tab drops the buffer.
Questions about JSON to XML
- How do I convert JSON to XML?
- Paste your JSON into the input (or drop a .json file). The XML appears in the output box as you type. Choose the root element name, the array item name, the attribute prefix, and the indent if the defaults do not fit, then press Copy or Download to save converted.xml. Everything runs in this browser tab.
- Does JSON to XML upload my file?
- No. Parsing and conversion run in your browser with JSON.parse and plain string building. There is no account and no server-side converter. Dropped files are read with FileReader in this tab; we do not upload them to Page Utils or write them to localStorage. Closing the tab drops the buffer.
- How do I make XML attributes from JSON?
- Prefix the key with @ — for example {"city": {"@id": "1", "name": "Chennai"}} becomes <city id="1"><name>Chennai</name></city>. Use #text for the element's own text when it also has attributes: {"deposit": {"@currency": "INR", "#text": "100000"}} becomes <deposit currency="INR">100000</deposit>. You can switch the prefix to - or _, or turn attributes off so every key becomes an element.
- How are JSON arrays converted to XML?
- An array under a key repeats that key as sibling elements, so {"city": ["Chennai", "Pune"]} becomes <city>Chennai</city><city>Pune</city>. That matches how XML to JSON reads repeated tags, so the two pages round-trip. A top-level array, or an array nested directly inside another array, has no key name, so each entry uses the array item name (default item). An empty array writes no elements and is listed as a note.
- What root element does the XML get?
- XML needs exactly one root element. If your JSON is an object with a single key (for example {"cities": {…}}), that key becomes the root. Otherwise the whole value is wrapped in the root element name you set (default root). Untick “Use a single top-level key as the root” to always wrap in your root name.
- What happens to keys that are not valid XML names?
- XML element names cannot contain spaces or most punctuation and cannot start with a digit. The converter replaces invalid characters with _ and adds a leading _ when needed — "first name" becomes <first_name> and "2024" becomes <_2024>. Every rename is listed under the status line so nothing changes silently. Special characters inside values are escaped as &, <, >, and " instead.
- What happens if my JSON is invalid?
- You get a short parse error next to the input (for example a trailing comma or single-quoted key) and the XML stays empty. The page does not guess or repair your JSON. Fix it — the JSON Formatter at /developer/json-tidy/ can help — and paste again. Nothing is uploaded.
- Is there an XML to JSON reverse?
- Yes, on its own URL: /file-conversion/xml-to-json/ converts XML back to pretty JSON with the same @attribute and #text conventions. This page is JSON → XML only; each direction has one canonical trailing-slash URL and no /in/ prefix. Neither page validates against an XSD or DTD.
What else can I open?
- JSON to CSVConvert JSON to CSV (and back) entirely in the browser.
- JSON Schema GeneratorGenerate a JSON Schema from a JSON sample in the browser — no upload.
- JSON to ExcelConvert JSON to a real Excel .xlsx file in the browser — nested keys flattened, nothing uploaded.
- CSV to ExcelTurn a CSV or TSV table into a real .xlsx workbook locally in the browser.
- XML to JSONConvert XML back to pretty JSON locally in the browser.
- XML FormatterPretty-print or minify XML locally in the browser.
These tools run in your browser. Page Utils does not store, upload, or write to localStorage the keys, tokens, or text you paste. Results are a convenience aid, not legal, tax, or security advice.