Skip to main content
7BBusyBoss

JSON to XML Converter — Free Online, In-Browser

Convert JSON to XML in your browser. Watch arrays become repeated tags, unsafe key names turn to 'item', and understand why round-tripping is not safe.

No limitsZero data leaksSuper fast

JSON to XML Converter

Files never leave your browser
View:

0 lines · 0 chars · 0 B

0 lines · 0 chars · 0 B

You're on 7BusyBoss — 300+ free tools that run instantly in your browser. No signup, nothing uploaded.

Browse all Data Converters
About this tool

Arrays become repeated tags, and the array-ness disappears

JSON arrays are a core data structure, but XML has no native equivalent. This converter handles an array by repeating the same element once per item — no wrapper element is introduced. So {"fields": ["math", "cs"]} produces two sibling tags:

<root>
  <fields>math</fields>
  <fields>cs</fields>
</root>

The consequence shows up at the edge case. A one-element array collapses to a single tag that is byte-identical to the same key holding a plain value — both {"fields": ["math"]} and {"fields": "math"} emit exactly <fields>math</fields>. Nothing in the XML records which one you started with, so a converter reading it back has to guess, and it will guess "plain value". This is the classic reason JSON → XML → JSON is not a safe round trip: the trip is lossless right up until a list happens to have one item in it, which is precisely the case your test data is least likely to cover.

Invalid key names silently become the tag "item"

XML element names must start with a letter or underscore and may then contain only letters, digits, underscores, dots and hyphens. A JSON key that breaks that rule — one starting with a digit, containing a space, or holding a character like @ — is replaced with the literal tag name item, and the original key is discarded. There is no warning. {"2024 total": 15000} becomes:

<root>
  <item>15000</item>
</root>

The label is simply gone, and nothing in the output hints that it ever existed. Keys of this shape are common in exported data — year-prefixed columns, keys with spaces from spreadsheet headers, @-prefixed metadata keys from other XML converters — so it is worth scanning your keys before converting rather than discovering the loss later. Renaming 2024 total to total_2024 first preserves the meaning.

No attributes, everything is an element

XML supports both elements and attributes; JSON has no concept of an attribute, so this converter never produces one. Every value becomes an element, and primitives become that element's text content, escaped for ampersand, less-than, greater-than and double-quote. Null values and empty objects both become self-closing tags — {"a": null, "b": {}} gives <a /> and <b />, another pair that the XML cannot tell apart afterwards.

The output always opens with the declaration <?xml version="1.0" encoding="UTF-8"?> and wraps everything in a single element literally named root, because XML permits exactly one root element and JSON supplies no name for it. Nesting is indented two spaces per level. Invalid input produces an error beginning Invalid JSON: followed by the parser's own message.

Both formats nest, so this conversion keeps the structure — unlike flattening either one into a table, where the nesting has nowhere to go. The XML to JSON converter goes back the other way.

How to use the JSON to XML Converter

Takes about a minute. No signup, no download, your data stays in your browser.

  1. 1
    Open the tool. Scroll up to the JSON to XML Converter above — it loads instantly in your browser, no install needed.
  2. 2
    Enter your values. The fields come pre-filled with realistic defaults so you can see how it works — replace them with your own numbers.
  3. 3
    Read the result. The output updates instantly. Copy or share it — nothing is uploaded to a server, everything stays on your device.

Frequently asked questions

Common questions about the JSON to XML Converter.

Why does my array become repeated tags instead of a list element?

XML has no array type, so the converter repeats the same tag once per item rather than inventing a wrapper element. This produces clean, readable XML, but the fact that the values came from an array is not recorded anywhere in the output.

Is converting JSON to XML and back a safe round trip?

No, and the failure is subtle. A one-item array produces XML identical to the same key holding a plain value, so nothing distinguishes them on the way back. Null and an empty object also collapse to the same self-closing tag. Your data may round-trip perfectly until a list happens to contain exactly one element.

What happens to keys that start with a number or contain spaces?

They are silently renamed to the tag name item and the original key is discarded, because XML element names must begin with a letter or underscore and cannot contain spaces. No warning is shown. Rename such keys before converting — turning 2024 total into total_2024 keeps the meaning intact.

Can this converter produce XML with attributes?

No. JSON has no notion of attributes, so every value becomes an element and nothing becomes an attribute. If you need attribute-based XML for a specific schema, this tool cannot produce it and you will need a converter driven by that schema.

What does the XML output look like structurally?

It opens with the XML declaration line, then wraps everything in a single element named root, since XML allows only one root and JSON gives no name for it. Each nesting level adds two spaces of indentation, and text content is escaped for ampersand, less-than, greater-than and double-quote characters.

Community rating

Discussion (0)

No comments yet. Start the discussion.