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
EN – Language: English
Free tool, no upload, no account

XML to JSON Converter
Readable JSON From Any Feed

Paste a feed, an API reply, or a config file into this XML to JSON converter and you will get clean JSON back. All attributes, lists, and text will be maintained.

  • FreePrice
  • JSONOutput
  • NoneSign-up
  • In your browserRuns

XML to JSON 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 JSON to XML

Your browser does all of the work here, in this tab. We upload nothing, store nothing and log nothing.
Add a link to this tool on your own site

Copy the code below and drop it into your page. It places a link to this free tool.

At a glance

Jobs This XML to JSON Converter Handles for You

The XML-JSON Converter processes an XML file into a format that can be easily understood by the human eye in the form of JSON Objects and Lists. The XML tags are translated into JSON Object Keys and the XML tag content is translated into JSON Object Value. All data is preserved. Since your browser is processing the XML file directly, no data from any source (such as feed or system) will travel through a server.

The world’s most commonly used format for storing and transmitting data is XML. Although XML is older and has more words than JSON, it stores a large portion of the world’s data. Examples include bank statements, shipping labels, product feeds, and governmental systems. But, most developers who write code for the internet prefer JSON. The Denwix page fills the void created by this discrepancy.

The easy part is switching from brackets to tags. What’s difficult is maintaining the meaning -- i.e., identifying which items are attributes, which ones represent lists of things, and where the text goes. The conversion process is governed by a single rule for each type of item, and after making the identification, it reports back on what it has discovered.

How Each XML Part Becomes JSON

Each of the elements is used as a key in the object and the content of the element is used as the value. If an element contains only text it will be converted into a simple string value, i.e., "title": "Midnight Rain". When an element contains multiple elements then it will be converted into an object that has one key-value pair for each of the child elements.

Diagram of an XML book converted to JSON: the id attribute becomes @id and two tag elements become a list
Attributes are preceded by an "@", text to the right of attributes is labeled with "#text", and any multiple tag entries are made into a list.

Attributes keep an @ in front, so id="bk101" becomes "@id": "bk101". When an element has attributes and text together, the text goes under a #text key. Because the same two conventions work in reverse, our JSON to XML converter can rebuild the original file.

Repeated Tags Become Lists Everywhere

XML doesn’t have a native list type. Rather than having a list type, XML just repeats the element; so, for example, if you see three "tag" elements together, that would indicate a list of three. When using this conversion tool, those repeated elements are converted into a JSON array.

XML to JSON converter output where a book with one tag still gets a list, as the checks table explains
A single tag still becomes a list when the same tag repeats elsewhere.

But, a simple converter will create a problem. A book with two tags will have a list, but a book with only one tag will be represented as a plain string. So, the structure of the JSON will change from record to record. This program recognizes this pattern and converts each single tag into a one-element list. Because of this, programs that iterate through tags can function correctly for every book.

XML to JSON With Numbers and Booleans Kept

The price is also text. The converter will keep it as such by default, as this is the best option for keeping track of IDs and codes. When you wish to convert the text to numbers and booleans (JSON), you must enable number detection.

XML to JSON converter with number detection on, writing prices as JSON numbers while text stays readable
Switch on number detection and prices come out as real JSON numbers.

When you use Type detection, it changes 44.95 into a number and true into a boolean. But, any value that begins with a zero (like a zip code) remains as text since converting it to a number would alter its form.

Feeds, Sitemaps and SOAP Replies

An RSS feed is a channel element containing a list of item elements. When converted to a channel object, it will contain a list of items; so, each post will have its title, link and date next to each other. Sitemaps are similar to this: each url element becomes an entry, with its loc and lastmod being used as keys.

SOAP responses generated by earlier payment and shipping APIs use multiple layers of envelopes to enclose the actual useful info. This converter preserves all of these envelope layers, including namespace prefixes like soap:Body. So, you will be able to view the entire response structure before selecting the specific section that your application needs.

Namespaces are guaranteed not to conflict, as long as the namespace prefix is maintained within each key. So, g:price (from a product feed) and price (from the main document) will always be treated as two distinct keys.

Safe With Untrusted XML

Some XML files have the ability to declare their own entities in a DOCTYPE. A malicious file can then use those entities to retrieve local files or to expand the entity into millions of characters. Security professionals refer to this as the XXE attack described by OWASP.

This converter will never expand the declared entities, and the checks table will tell you if the file has attempted to declare any. As the file is being read in your web browser, it can’t access any content on this site.

What Happens When the XML Breaks the Rules

When you have a missing closing tag, an unescaped ampersand or two root elements, your XML is not valid. At this point, the converter will stop, tell you why, and give you the line and column number of the error. Once the converter tells you the line and column, it puts the cursor there. Now the error takes seconds to fix.

The XML to JSON converter reporting a mismatched closing tag with its line and column, next to the Show me where button
The converter reports broken XML with the exact line, and one click takes you there.

XML to JSON in the Browser, One Step at a Time

Developers can test their older SOAP or payment API using the conversion process when writing in modern languages. Marketers can read a product feed or sitemap with no need to use an XML editor. Analysts convert government exports into JSON formats and then import the data into either a notebook or dashboard.

The rules for well-formed XML live in the W3C XML specification, and this reader follows them strictly. Once you have the JSON, our JSON formatter can indent it, sort its keys or squeeze it onto one line.

Video guide

Watch the XML to JSON Converter in Use

This brief video shows each step from start to finish. Choose your language below, and switch on captions if they help.

Four steps

Turning XML Into JSON on Denwix

From feed to JSON in less time than it takes to open an editor.

  • Add the XML

    Paste it, drop an .xml file on the box, or open one. The sample is a small book catalog.

  • Choose the types

    Leave number detection off to keep every value as text, or turn it on for real numbers.

  • Read the checks

    Find out what lists have been saved, which entities were not saved and how far down the data can go.

  • Take the JSON

    Copy it or download a .json file, indented or on one line.

Why it helps

JSON You Can Actually Code Against

The design of the predictable shapes are what will make the JSON predictable, not how nice looking the JSON is.

  • Attributes never lost

    Every attribute lands under an @ key right beside the element it belonged to.

  • Consistent lists

    A tag that repeats anywhere becomes a list everywhere, even with one item.

  • Text kept in place

    Text beside attributes goes under #text, so none of it disappears.

  • Optional real types

    Numbers and booleans on request, while codes with leading zeros stay text.

  • Entity attacks blocked

    DOCTYPE entities are never expanded, and the checks say when a file tried.

  • Exact error lines

    When the XML is broken, the converter names the exact line and column.

Before you convert

Rules for XML That Converts Cleanly

Nearly every odd conversion result comes down to one of these points.

  • Check that the document has a single root element. Everything must sit inside a single outer tag, or the XML is not well formed.
  • Close every tag. Each opening tag needs a matching closing tag, or it must close itself with />.
  • Escape ampersands in text. Replace a plain & sign with its entity, or the parser reads it as the start of one.
  • Match tag names exactly. XML is case sensitive, so an opening Price and a closing price do not match.
  • Quote every attribute value. Both single and double quotes work, but a bare value breaks the file.
  • Save the XML as UTF-8 before pasting. It holds every script, and it matches the declaration most files carry.
  • Avoid custom entities. The converter ignores them for safety, so spell the text out instead.
  • Check the depth. A deeply nested file becomes deeply nested JSON, which is harder to use.
Common traps

Six XML to JSON Mistakes

Each one produces JSON that looks fine until code tries to read it.

  • Dropping attributes

    Some converters throw attributes away, so IDs and currencies vanish.

  • Lists that change shape

    One record gets an array and the next a string, and loops break.

  • Losing mixed text

    Text beside attributes disappears unless it gets its own key.

  • Rounding codes

    Turning 00123 into the number 123 changes an order code for good.

  • Expanding entities

    A parser that follows DOCTYPE entities can leak files or freeze.

  • Guessing past errors

    Silently fixing broken XML hides the real problem in the source system.

Questions

Questions About the Denwix XML to JSON Converter

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

Enter the XML in the space given, or upload the file from your computer. The JSON will appear right next to the XML and will be ready for you to copy or download.

How does the converter mark XML attributes in the JSON?

Each of these keys will have an @ symbol before them and be put into the object associated with their respective element. As an example, id="7" would be changed to "@id": "7".

Why does the JSON contain a #text key?

The converter uses "#text" as a name for the element’s text when it also contains attributes, because this is a standard used by many developers.

Why is a single item shown as a list?

This is because that same item appears again at another location. So, keeping the items as part of a list ensures all records have the same format.

Why do my numbers show up inside quotes?

XML stores everything as text, and the converter keeps it that way by default. Turn on number detection to get real numbers.

Are XML namespaces kept?

Yes. All prefixes remain exactly the same as in the original document (for example, g:price remains g:price), and xmlns declarations are represented by @ keys.

What about comments and CDATA?

The converter will ignore any comments in the XML file, because JSON doesn’t support comments. Any CDATA section of the XML will be converted into standard text.

Can I convert an RSS feed or sitemap?

Yes. You can paste the sitemap XML or feed and every single element of each item/URL will be a separate entry within a list.

Why did the converter stop at a closing tag?

Because of either a simple typing error or a failure to close a previous tag, the closing tag does not correspond to the current open tag. This problem will be listed as such, and both tags will be identified by name and the line number where the opening tag began.

Can every value stay as text?

Yes. Denwix will turn this setting on for you. If you leave number detection turned off then all of your values will remain as strings in the exact same format as they appear in the XML, including prices, dates and codes.

Does it read HTML too?

Only XHTML, which follows XML rules. Ordinary HTML allows unclosed tags such as <br>, so the strict reader stops on them by design.

How large a file will this Denwix tool accept?

Files that are very large (several megabytes) convert quickly. Large input files convert when you click the convert button as opposed to converting after each letter.

Does my XML leave my computer?

No. Your browser converts it locally, so nothing is sent to the site.

Next steps

More Tools for Working With XML and JSON

Useful once the JSON is ready.

Ready to Read Your XML as JSON?

As soon as you paste the XML, the clean JSON will appear. This free XML to JSON converter needs no registration and stores the resulting JSON file on your own computer.

Prefer Denwix on GoogleReview Denwix on Google