JSON to XML Converter
Paste a JSON object to convert it into formatted XML.
Result
How it is calculated
The input must be a JSON object, meaning curly braces with keys, not a bare array, a bare number or invalid JSON. Every key becomes an element inside a <root> tag, nested objects become nested elements indented by two spaces, and the values become the element text. Text is escaped, so &, < and quotes in values come out as XML entities. Booleans are written as true or false, and null becomes an empty element <key/>. Characters in key names other than letters, digits, hyphen and underscore are replaced with an underscore, and a name starting with a digit gets an underscore in front. Array items have no name of their own, so they become <_0>, <_1> and so on. The count is the number of elements created, nested ones included. The Valid line only says whether at least one element was produced: an empty object gives a bare root and is marked not valid, and it does not validate the XML against any schema.
Worked example
Paste {"name":"Ada & Co","age":36,"address":{"city":"Leeds"},"tags":["a","b"]}. The output has <name>Ada & Co</name> and <age>36</age> as first-level elements, then <address> containing <city>Leeds</city>, and <tags> containing <_0>a</_0> and <_1>b</_1>, all inside <root>. Counting name, age, address, city, tags, _0 and _1 gives 7 elements.
Common mistakes
- Pasting a top-level array such as
[1,2,3]. The tool needs an object with keys and returns nothing for a bare array. - Sending JSON with single quotes, trailing commas or unquoted keys. These are not valid JSON, so there is no output.
- Expecting XML attributes. Every value becomes element text; there is no way to produce
<item id="1">. - Expecting repeated tags for arrays, like several
<tag>elements. Items get the names_0,_1, which a strict schema will not accept. - Using key names with spaces or a leading digit and expecting them unchanged.
first namebecomesfirst_nameand1stbecomes_1st.
About this calculator
JSON and XML are both structured text formats for exchanging data, but they're not interchangeable: JSON uses key-value pairs and arrays, while XML wraps data in nested elements and attributes inside a required root tag. Converting between them means mapping each JSON key to an XML element name and recursively turning nested objects into nested elements.
Developers reach for this conversion when integrating with older or enterprise systems that only speak XML — SOAP web services, certain banking and government APIs, and legacy configuration formats — while newer parts of the same system work natively in JSON.
Was this helpful?
You can pick up to 3 reactions.
Popular calculators
Loan Calculator
Monthly payment, total interest and full amortization schedule.
Percentage Calculator
Percent change, percent of, and ratio calculations.
Discount Calculator
Calculate final price, savings, and discount amount.
BMI Calculator
Body mass index from height and weight (metric or imperial).
Age Calculator
Compute your exact age in years, months and days from a birth date.
Compound Interest Calculator
Calculate the final amount and interest earned with compounding.
All Calculators
- Loan Calculator
- Profit Calculator
- Discount Calculator
- BMI Calculator
- Percentage Calculator
- Ideal Weight Calculator
- Age Calculator
- Pregnancy Due Date Calculator
- Compound Interest Calculator
- BMR Calculator (Basal Metabolic Rate)
- Tip Calculator
- Fuel Cost Calculator
- Date Difference Calculator
- Sleep Cycle Calculator
- Daily Water Intake Calculator
- Simple Interest Calculator
- Heart Rate Zones Calculator
- Running Pace Calculator
- Pet Age Calculator
- Calories Burned Calculator
- Macro Calculator
- TDEE Calculator (Total Daily Energy Expenditure)
- Waist-to-Hip Ratio Calculator
- Honor Roll Calculator
- One Rep Max (1RM) Calculator
- Ovulation Calculator
- Electricity Cost Calculator
- Unit Price Calculator
- Savings Goal Calculator
- Break-Even Point Calculator
- Paint Calculator
- Course Grade Average Calculator
- Business Days Calculator
- Time Duration Calculator
- Fuel Economy Calculator
- Temperature Converter
- Tile Calculator
- Aspect Ratio Calculator
- Roman Numeral Converter
- Goal Weight Timeline Calculator
- Salary Converter (Hourly to Annual)
- Credit Card Validator (Luhn)
- Body Surface Area (BSA) Calculator
- Feels-Like Temperature Calculator
- Ohm’s Law Calculator
- PPI (Pixel Density) Calculator
- Molar Mass Calculator
- Zodiac Sign Calculator (Western + Chinese)
- IBAN Validator
- Shoe Size Converter
- Country Info & Dialing Code Lookup
- Time Zone Difference (World Clock)
- CAGR (Compound Annual Growth Rate) Calculator
- Rule of 72 Calculator
- Blood Alcohol Content (BAC) Calculator
- Lean Body Mass (LBM) Calculator
- Pythagorean Theorem Calculator
- Speed Converter
- Download Time Calculator
- Date Calculator (Add/Subtract)
No calculators found
Comments (1)
Treat the output as a quick structural draft. JSON arrays have no element names, so lists become numbered tags such as _0 and _1, and there is no way to produce XML attributes. If a target system expects a specific schema, plan to rename elements afterwards. Which odd structure did you try to convert?