Cookies This site keeps only what it needs to work. There is no analytics and no advertising on it today, and nothing here follows you to other sites. Read the privacy policy

Choose what to allow
+92 312 8299940Free Quote
Free tool, works offline once loaded

JSON to XML Converter
Well-Formed XML in One Paste

Paste your data into this JSON to XML converter and get tidy, valid XML back. It picks a root, names every tag safely and tells you what it adjusted.

  • FreePrice
  • XML 1.0Output
  • NoneSign-up
  • In your browserRuns

JSON to XML Converter

Converted in your browser, with every issue listed

Records
0
Depth
0
Size
0 B

Ready. Paste your data, open a file or try the sample.

Going the other way? Convert XML to JSON

Your browser does all of the work here, in this tab. We upload nothing, store nothing and log nothing.
The idea

Jobs This JSON to XML Converter Handles for You

This JSON to XML converter takes the objects, lists and values in a JSON document and writes the same data as XML elements. Every key becomes a tag, and every value sits inside one. The work happens in your browser tab, so the data stays with you.

The two formats look alike at first, but they follow different rules. XML needs exactly one root element, while JSON can start with a list. XML tag names cannot begin with a digit or contain spaces, while JSON keys can be almost anything. XML also has attributes, which JSON does not have at all.

So a good conversion makes a few decisions. This one makes them openly and lists each one in the checks table under the result. As a result, you always know why the XML looks the way it does.

How JSON Maps to XML Elements

An object becomes an element with child elements, one for each key. A plain value becomes the text inside its element. A list works differently, because XML has no list type. Instead, the element simply repeats: a key called book holding three items becomes three book elements in a row.

Diagram of a JSON book record mapped to XML, with the @id key turned into an attribute, the title key into an element and a tags list into repeated tag elements
Keys become elements, @keys become attributes, and a list becomes repeated elements.

Two special keys give you more control. A key that starts with @, such as @id, becomes an attribute on its parent element. A key named #text becomes the text of the element itself. Together they let you write almost any XML shape from plain JSON.

Choosing the Root Element

Every XML document has one outer element that holds everything else. When your JSON already has a single top-level key, such as {"catalog": {...}}, that key becomes the root, and the tool adds nothing extra.

JSON to XML converter with the root element named orders, wrapping a JSON list in an orders element with one item element per record
A list at the top gets a root you can name, with one item element per record.

When the JSON starts with a list or with several keys, the converter wraps it in a root element for you. Its default name is root, but you can type any name, such as orders or products. A list at the top also gets one item element per entry, so every record stays separate.

Convert JSON to XML With Safe Tag Names

JSON keys often break XML naming rules. A key like first name has a space, 2024 starts with a digit, and price($) contains symbols. Any of these would make the XML invalid, so the parser at the other end would refuse the whole file.

Keys with spaces, digits and symbols turned into legal XML tag names, with the checks table listing every adjusted key
The converter repairs illegal names and lists every change.

The converter repairs such names instead. A run of spaces or symbols becomes one underscore, so first name turns into first_name and price($) into price. A leading digit gets an underscore in front, while letters from any language stay as they are. It then lists the keys it changed in the checks, so no name changes without you knowing. The rules it follows come from the W3C XML specification.

Special Characters and Escaping

Some characters mean something in XML. In XML, & opens an entity and < opens a tag. Therefore the converter writes them as &amp; and &lt; inside text, and it escapes quotes inside attributes. The result opens cleanly in any XML reader.

Accents, emoji and every other script pass through untouched, because the tool writes the file as UTF-8. The optional declaration at the top says exactly that. Turn it off if the XML is going inside another document.

Attributes or Elements: Which to Use

Both hold data, so the choice is mostly about what the receiving system expects. As a rule of thumb, attributes suit short labels about an element, such as an id, a language or a currency. Elements suit the real content, and anything that can repeat or contain more structure.

Namespaces work too. Add a key such as @xmlns:g with the namespace address, then use prefixed keys like g:price. The converter keeps those names exactly, because a colon between two valid parts is legal in XML. That means product feeds and other namespaced formats come out ready to use.

When the JSON Itself Has an Error

The converter reads your JSON strictly, following RFC 8259. A trailing comma, a single quote or a missing bracket stops the conversion with the exact line and column. One click on Show me where puts the cursor on the problem.

The JSON to XML converter reporting a trailing comma with its line and column, next to the Show me where button
The converter names a JSON mistake and its exact position before it writes any XML.

JSON to XML Online, for Real Work

XML is still everywhere behind the scenes. Banks and payment gateways exchange it. Many shipping, invoicing and government systems accept nothing else. Sitemaps and RSS feeds are XML too, which is why our XML sitemap generator writes it.

Meanwhile, most modern APIs speak JSON. So developers often sit between the two, taking JSON from one service and feeding XML to another. This tool covers that step in seconds, and the reverse trip is one click away on the XML to JSON page.

Four steps

Turning JSON Into XML on Denwix

Most files finish converting before you finish reading the checks.

  • 1

    Paste JSON into the Denwix box, or open a .json file

    Use the input box, drop a .json file on it, or open one. The sample shows attributes and lists at work.

  • 2

    Name the root

    Type the outer element name if the JSON starts with a list or several keys. Otherwise the tool finds it for you.

  • 3

    Set the layout

    Pick two spaces, four spaces, tabs or one line. Keep or drop the XML declaration.

  • 4

    Check and take it

    Read what was adjusted, then copy the XML or download it as a file.

Why use this one

XML That Other Systems Accept

A converter is only useful if the receiving system can read what it writes.

  • Always one root

    The tool wraps lists and multi-key objects, so the document always stays well formed.

  • Attributes from @keys

    Write id or currency as real attributes, the way many schemas expect.

  • Legal tag names

    The tool repairs spaces, digits and symbols, then lists each repair.

  • Correct escaping

    The converter escapes &, < and quotes so the XML stays valid.

  • Exact numbers

    Long IDs and prices keep exactly the digits they have in the JSON.

  • Private by default

    Your payloads never leave the browser, even for large files.

Good practice

Rules for JSON That Becomes Good XML

Shape the JSON well, and the XML comes out exactly as a partner system expects.

  • Wrap the data in one named key. A top key such as invoice becomes the root, so the tool adds no generic wrapper.
  • Use singular names for list keys. A list under item produces item elements, which read naturally in XML.
  • Keep keys free of spaces. Use first_name or firstName, and the tag keeps the exact same name.
  • Mark attributes with @. Only simple values can be attributes, so keep objects and lists as child elements.
  • Use #text for mixed elements. An element with attributes and text needs its text under the #text key.
  • Match the target schema. If a partner sent you an XSD file, compare tag names and order against it.
  • Avoid empty lists. An empty list writes no elements at all, which some schemas treat as missing data.
  • Leave the XML declaration on when you save a file. Standalone files should start with it, while embedded fragments usually should not.
Easy to get wrong

Six JSON to XML Mistakes

Each of these produces XML that a strict parser will reject or misread.

  • More than one root

    Two top-level elements make the file invalid, however neat it looks.

  • Tags starting with digits

    A key like 2024 cannot become a tag name without a change.

  • Unescaped ampersands

    A company name such as Smith & Sons breaks every parser if written raw.

  • Lists squashed into one tag

    Joining list items into one text value hides the separate records.

  • Objects as attributes

    An attribute holds one simple value, never a nested structure.

  • Forgetting the encoding

    A file saved in another encoding garbles every accented name.

Questions

Questions About the Denwix JSON to XML Converter

What are the steps to turn JSON into XML on Denwix?

Paste the JSON into the input box or open a file. The XML appears beside it, ready to copy or download.

How do I make an XML attribute?

Start the key with @, for example "@id": "bk101". It then appears as id="bk101" on the parent element.

How do JSON arrays turn into XML?

Each item becomes its own element with the same tag name. XML has no list type, so repeated elements are the standard way.

Why was my data wrapped in a root element?

XML allows only one outer element. Your JSON started with a list or several keys, so it needed a wrapper. You can rename it.

Why did a tag name change?

The original key broke the XML naming rules, perhaps with a space or a leading digit. The checks list every such change.

How are null values written?

A null becomes an empty element, such as <phone/>. That keeps the field present without inventing a value.

Must the XML start with a declaration line?

Not always. Standalone files should carry it, but you can turn it off when the XML goes inside another document.

Can I turn the XML result back into JSON later?

Yes. The XML to JSON converter reads attributes as @keys and repeated tags as lists, so the round trip keeps its shape.

Why do ampersands look different in the XML?

Inside XML text, an ampersand must be written as an entity: the & sign, the letters amp and a semicolon. Any XML reader turns it back into a plain & when it opens the file, so your data stays the same.

Can the result be used as an RSS feed or sitemap?

Yes, if your JSON follows that format. Put the channel or urlset as the single top key, add the required namespace with an @xmlns key, and the output keeps the exact names.

Can the Denwix converter write XML namespaces?

Yes. Declare the namespace with a key such as @xmlns:g, then use prefixed keys like g:price. Both pass through unchanged.

How large a file will this Denwix tool accept?

Files running to several megabytes pose no problem. Very large input converts when you press the button rather than on every keystroke.

Does the JSON I paste ever leave this Denwix page?

No. Only your browser performs the conversion. Nothing reaches this site or any other server.

Related tools

More Free Tools for Data Formats

Handy on either side of the conversion.

Ready to Turn Your JSON Into XML?

Paste the JSON and valid XML appears at once. The JSON to XML converter is free, needs no account and keeps your data in your browser.