Quick Answer
Paste your JSON into the box (or open a .json file) and the XML appears instantly. Objects become nested elements, each array item repeats the element named after its key, keys that start with @ become attributes and #text becomes an element's text. Names that are not valid in XML are fixed automatically and special characters are escaped, so you can copy or download a well-formed .xml file straight away.
Why Convert JSON to XML?
Modern web APIs speak JSON, but a large part of the business world still runs on XML: SOAP web services, banking and payment messages, e-invoicing and government portals, ERP and accounting imports, product feeds, RSS, sitemaps, Office documents and Android resources. When data from a JSON API, a NoSQL database or a JavaScript app has to reach one of these systems, it needs converting.
This JSON to XML converter (JSON से XML) does that instantly in your browser. It follows widely used conventions — arrays become repeated elements, @ keys become attributes and #text becomes element text — and it guarantees well-formed output by fixing invalid names and escaping special characters. There is no upload, no sign-up and no limit on how often you use it.
How to Use It
- Paste JSON into the box or press Open file to load a .json file. A sample is already loaded to show how attributes and arrays work.
- Watch the status line: it confirms the JSON is valid or shows the exact parser error.
- Set the root element (used when the JSON doesn't have a single top-level key) and the name for array items (used for top-level arrays).
- Choose options: @/#text handling and pretty printing.
- Copy or download the XML.
How JSON Maps to XML
JSON and XML model data differently — JSON has objects, arrays, numbers, booleans and null; XML has elements, attributes and text. The converter uses these rules:
| JSON | XML |
|---|---|
{"name": "Asha"} | <name>Asha</name> |
{"marks": [91, 88]} | <marks>91</marks><marks>88</marks> |
{"@id": "b1"} inside an object | id="b1" attribute on that element |
{"#text": 250} inside an object | 250 as the element's text |
{"city": null} | <city/> |
true, 42 | Text true, 42 |
{"a b": 1} | <a_b>1</a_b> |
Choosing the Root Element
An XML document must have exactly one root element. JSON doesn't have that rule, so the converter decides like this:
- An object with one key whose value is an object — for example
{"catalog": {…}}— uses that key as the root:<catalog>…</catalog>. This is the most natural result for JSON that was itself converted from XML. - Any other object is wrapped in the root name you choose (default
root). - A top-level array like
[{…}, {…}]becomes<root><item>…</item><item>…</item></root>, with both names editable — for examplestudentsandstudent.
Attributes and Text: the @ and #text Convention
XML can store values as attributes (<book id="b1">) or as child elements. JSON has no attributes, so a common convention — also used by many libraries and by our XML to JSON converter — marks them with @. Similarly, #text holds an element's own text when it also has attributes:
{"price": {"@currency": "INR", "#text": 250}}
→ <price currency="INR">250</price>
Because both converters use the same rules, you can turn XML into JSON, edit it in code, and turn it back into equivalent XML. If your JSON genuinely has keys that start with @ or # and you want them as ordinary elements, untick the option: they become _id-style element names instead.
Worked Example
Here is a typical API-style response and what the converter produces with default settings:
{"orders": {"@count": 2, "order": [
{"@id": "101", "customer": "Asha", "items": ["Pen", "Notebook"], "total": 55},
{"@id": "102", "customer": "Rohit", "items": ["Bag"], "total": 399, "coupon": null}
]}}
<orders count="2">
<order id="101">
<customer>Asha</customer>
<items>Pen</items>
<items>Notebook</items>
<total>55</total>
</order>
<order id="102">
…
<coupon/>
</order>
</orders>
Notice how the single top-level key orders became the root, the @count and @id keys became attributes, the order array produced one element per order, the items array repeated its element, and null became an empty <coupon/>. If a receiving system expects <items><item>Pen</item>…</items> instead, reshape the JSON to "items": {"item": ["Pen", "Notebook"]} before converting — the converter will follow the structure exactly.
Works on Any Device
All you need is a modern browser on Windows, macOS, Linux, Android or iPhone. Nothing is installed, and because the converter is plain JavaScript with no external libraries, it keeps working even if your internet connection drops after the page has loaded.
Making Every Name Valid
JSON keys can be any string — "first name", "2026", "price(₹)", even an empty string. XML element and attribute names cannot contain spaces or most symbols, cannot start with a digit, and must not begin with "xml". The converter cleans names automatically: spaces and symbols become underscores, names starting with a digit or "xml" get a leading underscore, and empty names become item. Unicode letters such as Hindi are allowed and kept. If you need exact names for a target system, rename the keys in your JSON first — XML names are case-sensitive.
Escaping and Well-Formed Output
Values are escaped so the document always parses: & becomes &, < and > become < and >, and quotes inside attributes become ". Control characters that XML 1.0 forbids are removed. The output starts with an XML declaration specifying UTF-8, so Hindi, emoji and every other script survive intact.
Common Uses
- Integrating APIs with legacy systems: take a JSON response and produce the XML a SOAP service, bank interface or ERP expects.
- Feeds and syndication: build product or content feeds in XML from JSON exports.
- Configuration: convert JSON settings into XML configuration files for Java, .NET or Android projects.
- Testing and mocking: create XML fixtures from JSON test data.
- Data migration: move records from a NoSQL database into an XML-based import format.
- Learning: see side by side how JSON structures map to XML trees.
JSON vs XML
| JSON | XML | |
|---|---|---|
| Syntax | Braces, brackets, key–value pairs | Opening and closing tags |
| Data types | String, number, boolean, null, array, object | Text only (types come from schemas) |
| Attributes | No | Yes |
| Comments | No | Yes |
| Size | Smaller | Larger |
| Validation | JSON Schema | XSD, DTD |
| Typical home | Web APIs, apps | Enterprise, documents, feeds |
Because XML stores everything as text, numbers and booleans become their text form (42, true). If the receiving system needs types, it usually gets them from an XML schema.
Fixing Invalid JSON
The converter uses the browser's strict JSON parser, so common mistakes are reported immediately with a position in the message: single quotes instead of double quotes, trailing commas after the last item, unquoted keys, comments, or a missing bracket. Paste the JSON into our JSON Formatter to pinpoint and fix the problem, then come back to convert.
What About Namespaces and Schemas?
Some formats require XML namespaces (for example xmlns="…" on the root) or must validate against an XSD schema. You can add a namespace declaration by putting an attribute key on the root object, such as "@xmlns": "http://example.com/schema", and it will be written exactly as xmlns — the one name starting with "xml" that is allowed through, because it is a legal namespace declaration. Prefixed names like ns:item are not supported because the colon is replaced, so for heavily namespaced formats, convert first and then add prefixes in an editor. For validating against a schema, use the tools your target system provides after converting.
Large Files
Files up to 50 MB can be opened. The output box shows the first 200,000 characters so the page stays fast, but Copy and Download always include the complete XML. Deeply nested or very large documents are best handled on a laptop or desktop browser, which has more memory than a phone.
Tips for Clean Results
- Wrap your data in a single named key —
{"orders": {"order": [...]}}— to control the root and record names exactly. - Use plural/singular pairs for arrays: the array key becomes the repeated element, so name it in the singular (
order), inside a plural parent (orders). - Keep IDs as @attributes for compact, searchable XML.
- Turn off pretty print when the file goes straight into another program, to save space; keep it on when people need to read or review the XML.
Privacy
API responses often include personal or business data. This converter runs entirely in your browser with plain JavaScript — no libraries, no servers, no uploads, and nothing is stored after you close the tab.
Quick Glossary
- Element: an XML tag pair such as
<city>Patna</city>. - Attribute: a name="value" pair inside a start tag.
- Root element: the one outer element that contains the whole document.
- Well-formed: XML that follows the syntax rules so any parser can read it.
Why Use This Converter?
It handles arrays, attributes and text nodes with clear, predictable rules, always produces valid XML, works offline once loaded and keeps your data private — free. Related tools: XML to JSON, JSON to CSV and CSV to XML.
JSON to XML Converter — Key Facts
| Input | JSON text or .json file |
|---|---|
| Output | UTF-8 XML |
| Arrays | Repeated elements |
| Attributes | Keys starting with @ |
| Text nodes | #text key |
| Privacy | Runs in your browser |
Frequently Asked Questions
How do I convert JSON to XML?
Paste the JSON into the box or open a .json file. The XML is generated as you type; copy it or download it as an .xml file.
How are JSON arrays converted?
Each item of an array becomes a repeated element named after the array's key. For example "marks": [91, 88] becomes
How do I create XML attributes from JSON?
Start the key with @. {"book": {"@id": "b1", "title": "Godan"}} becomes
What does #text do?
A #text key sets the element's own text, so {"price": {"@currency": "INR", "#text": 250}} becomes
What becomes the root element?
If the JSON is an object with a single key, that key becomes the root. Otherwise everything is wrapped in the root name you choose (default root).
What happens to keys that aren't valid XML names?
Spaces and symbols become underscores, and names starting with a digit or 'xml' get a leading underscore, so the XML is always valid.
How is null handled?
null becomes an empty element such as
Are special characters escaped?
Yes. &, <, > and quotes are converted to entities, and invalid control characters are removed.
What if my JSON is invalid?
The tool shows the JSON parser's error message so you can find the problem. Our JSON Formatter can help fix it.
Are my files uploaded?
No. The conversion happens entirely in your browser.
Can I convert XML back to JSON?
Yes — use our XML to JSON converter, which uses the same @attribute and #text conventions, so data can round-trip.
Is it free?
Yes, completely free with no sign-up.
JSON to XML, Instantly!
Attributes, arrays and valid names — free and private.
Explore More Prompt Minds Tools
JSON to XML Converter works great alongside our other free tools. Every Prompt Minds tool runs entirely in your browser — no sign-up, no uploads, no watermarks. Browse all free tools.
