A sitemap is a simple list wearing a complicated costume. Underneath the markup it is just URLs and dates, but in XML form even basic questions are awkward: how many URLs are in the file, which pages carry the oldest lastmod dates, how many URLs sit under one folder. Answering them means scrolling, searching and hoping the formatting is regular. Convert the sitemap to JSON and it becomes data your tools already understand: an array you can count, sort and filter.

The conversion itself takes one paste. Ovatly's XML to JSON Converter runs in your browser using DOMParser, so the file is never uploaded, and it never fetches a URL: you bring the XML to it. This guide shows the conversion, the exact shape that comes out, and the one caveat that catches people out.

Contents

  • Quick answer
  • What a sitemap looks like as JSON
  • Why JSON is easier to analyse
  • How to convert a sitemap, step by step
  • Worked example: a three-URL sitemap
  • The single-URL shape caveat
  • Limitations and honest tradeoffs
  • Common mistakes
  • FAQs
  • Conclusion
  • References

Quick answer

Copy the sitemap's XML, paste it into the XML to JSON Converter and convert. The repeated url elements come out as an array of objects, and text-only elements such as loc and lastmod become plain text values, ready to sort, count and filter in a spreadsheet, a script or a JSON viewer. Two things to know before you start: the namespace declaration is not carried over, which does not affect the URL values, and a sitemap with a single url element produces a single object rather than an array.

What a sitemap looks like as JSON

The converter maps XML structure to JSON structure with a small set of rules, and a sitemap exercises most of them. The root element becomes the top-level key, so everything sits inside a urlset object. Each child element becomes a key, and when the same element repeats, the repeats are collected into an array in document order: that is what happens to url. An element that holds only text becomes that text itself, so loc and lastmod arrive as plain strings, with no wrapper object around them.

Two parts of the original file do not make the trip. The xmlns namespace declaration on urlset is not carried over, because namespaces have no JSON equivalent here. Comments and processing instructions are also dropped. Neither loss touches the data you analyse: every URL and every date survives intact.

A sitemap index file converts by the same rules. Its repeated sitemap elements become an array of objects, each holding the child sitemap's loc and lastmod, so you can analyse the index first and then convert whichever child sitemaps you need.

Why JSON is easier to analyse

Counting URLs stops being a chore: it is the length of the url array. Sorting by freshness is a sort on the lastmod strings, and because sitemap dates are written as YYYY-MM-DD, plain text sorting puts them in true date order. Filtering is a substring test on loc, so pulling out every URL under /tools/ or /blog/ takes one line in a script or one filter in a spreadsheet that accepts JSON.

Just as useful, JSON is the native input of most analysis tools. The converted file loads straight into a script, a notebook or a JSON viewer with no XML parser to configure, and the array-of-objects shape lines up with the rows-and-columns way people actually inspect a URL list.

How to convert a sitemap, step by step

  1. Get the XML. Open the sitemap in your browser, view the page source if the browser renders it as a tree, select all and copy. The XML to JSON Converter never fetches a URL, so pasting the markup is the way in.
  2. Paste the XML into the converter's input.
  3. Convert. If the XML is not well formed, the converter reports the problem in plain words rather than guessing, so fix the markup it points at and convert again.
  4. Check the shape before anything else: confirm that url is an array, and note the one case where it will not be, covered in the caveat section below.
  5. Copy the JSON into your analysis tool and work there. Keep the original XML file untouched as your source.

Worked example: a three-URL sitemap

Here is a small sitemap fragment going in:

<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
  <url>
    <loc>https://example.com/</loc>
    <lastmod>2026-11-20</lastmod>
  </url>
  <url>
    <loc>https://example.com/tools/word-counter</loc>
    <lastmod>2026-11-25</lastmod>
  </url>
  <url>
    <loc>https://example.com/blog/how-to-resize-an-image-online</loc>
    <lastmod>2026-11-27</lastmod>
  </url>
</urlset>

And here is the JSON that comes out:

{
  "urlset": {
    "url": [
      { "loc": "https://example.com/", "lastmod": "2026-11-20" },
      { "loc": "https://example.com/tools/word-counter", "lastmod": "2026-11-25" },
      { "loc": "https://example.com/blog/how-to-resize-an-image-online", "lastmod": "2026-11-27" }
    ]
  }
}

Read it against the rules: three url elements became a three-item array, each loc and lastmod became a string value, and the xmlns declaration is gone. Counting gives 3, sorting by lastmod puts the homepage first, and filtering loc for "/tools/" leaves exactly one entry.

The single-URL shape caveat

Shapes vary between documents because a single occurrence stays single. A brand new site's sitemap with one url element converts to a url key holding one object, not a one-item array. Nothing is wrong with the conversion; the rule is consistent. But code written against a large sitemap, where url is always an array, will trip over the small one. The fix is on your side: after converting, check whether url is an object and wrap it in an array before your analysis runs. The same applies to any element that appears once in one file and many times in another.

Limitations and honest tradeoffs

Namespaces are not carried over, so namespaced extension data, such as the extra elements some sitemaps add for images or news, does not survive conversion. For a standard URL and date analysis that costs nothing; for extension data, work from the XML.

Conversion is structural, not a health check. A well-formed sitemap converts cleanly even if every URL in it is dead, because the converter reads markup, not the live web. It also reports well-formedness errors only: whether the file obeys the sitemap protocol's own rules is a separate question the conversion does not answer.

Finally, the JSON is a working copy. If the site changes, the sitemap changes, and a stale JSON file will happily mislead your analysis. Convert fresh each time the numbers matter.

Common mistakes

  • Pasting the sitemap's web address instead of its XML. The converter never fetches a URL. Open the sitemap, copy the markup, paste that.
  • Assuming url is always an array. A single-URL sitemap produces a single object. Check the shape first.
  • Treating lastmod as a parsed date. It is text. It sorts correctly as text, but date arithmetic needs your tool to parse it.
  • Analysing before fixing a well-formedness error. When the converter reports a markup problem in plain words, fix that first; output built on broken XML is not output at all.
  • Overwriting the original sitemap. The JSON is for analysis. Keep the XML as the source of truth.

FAQs

Does the converter fetch my sitemap from its URL? No. The converter never fetches a URL. Open the sitemap, copy the XML, and paste it in. Everything runs in your browser with DOMParser, so the file is not uploaded anywhere either.

Why is url an object instead of an array in my output? A single occurrence stays single. Repeated elements become arrays, but a sitemap with only one url element produces one object. Wrap it in an array in your own code before you treat the result as a list.

What happens to the xmlns namespace declaration? Namespaces are not carried over, so the xmlns declaration on the urlset element disappears in the JSON. The loc and lastmod values are unaffected, which is what matters for analysis.

Are lastmod values converted into real dates? No. An element that holds only text becomes that text, so lastmod stays a string exactly as written. Because sitemap dates use the YYYY-MM-DD format, they still sort correctly as text, and your own tool can parse them into dates if you need that.

Can I convert a sitemap index file as well? Yes. A sitemap index uses repeated sitemap elements instead of url elements, and repeated elements become an array in exactly the same way, giving you a list of your child sitemaps with their own loc and lastmod values.

Conclusion

An XML sitemap converts to JSON with one paste, and the result is the same list in a shape your tools can count, sort and filter: repeated url elements as an array, loc and lastmod as text, namespaces left behind. Mind the single-URL caveat and the file is ready to analyse. Once the JSON is in hand, our guide to validating converted JSON against the original XML shows how to check any conversion record by record before you trust it. For more guides in this series, see our Data and JSON Tools guides.

References