---
title: Is my XML sitemap valid? How to validate it with the Sitemap Validator
description: Search Console flags sitemap problems, or lists pages as excluded, and you need to know whether the sitemap itself is the cause. To validate an XML sitemap, confirm it parses, stays within the protocol limits and lists only URLs that return 200 and are meant to be indexed. Here's how with the free Sitemap Validator, what it means when it reports 10 URLs for a site with thousands of pages, and the commands that check the rest.
canonical: https://watchfor.io/blog/how-to-validate-an-xml-sitemap
---

# Is my XML sitemap valid? How to validate it with the Sitemap Validator

2026-10-04 · WatchFor Team · Guides · guides, seo, http

Search Console flags sitemap problems, or lists pages as excluded, and you need to know whether the sitemap itself is the cause. To validate an XML sitemap, confirm it parses, stays within the protocol limits and lists only URLs that return 200 and are meant to be indexed. Here's how with the free Sitemap Validator, what it means when it reports 10 URLs for a site with thousands of pages, and the commands that check the rest.

To validate an XML sitemap, check four things: the file is reachable and
returns 200, it parses as a `<urlset>` or `<sitemapindex>`, it stays within
the protocol limits (50,000 URLs and 50 MB uncompressed per file), and the
URLs it lists return 200 and are pages you want indexed. A sitemap that
parses can still be wrong if it points at redirects, error pages or
duplicates.

The free [Sitemap Validator](/sitemap-validator) handles the first part from
a WatchFor probe location: it finds the sitemap, checks that it parses,
counts its entries and requests a sample of them. No signup.

## What this tool answers

*Does my sitemap parse, and do the entries in it actually answer?* Reach
for it when Search Console reports sitemap errors or many "excluded" pages,
after changing the sitemap generator, or when you suspect the sitemap still
lists pages you deleted or redirected. For the question "can crawlers find
my sitemap at all?", see the companion guide
[how to check a sitemap](/blog/how-to-check-a-sitemap).

## A real example

### Validating an XML sitemap index

A common source of confusion: you run a validator on a site with thousands
of pages and it reports ten URLs. Is the sitemap truncated? We ran the
[Sitemap Validator](/sitemap-validator) on `developer.mozilla.org`:

![The Sitemap Validator after checking developer.mozilla.org: a green Sitemap found badge, 10 URLs, 5 sampled and 0 broken](/blog/how-to-validate-an-xml-sitemap-result.webp)

**Sitemap found, 10 URLs, 5 sampled, 0 broken**, in 1.6 seconds. The ten
"URLs" aren't pages. MDN's `/sitemap.xml` is a **sitemap index**: a list of
ten child sitemaps, one per language, each a gzipped file such as
`/sitemaps/en-us/sitemap.xml.gz`. The validator counts the index's entries
and checks that the first five child sitemaps answer. They all did.

That settles the structure. To validate the pages, we opened the English
child sitemap ourselves (commands below):

| Check | Result |
| --- | --- |
| Child sitemaps in the index | 10 |
| URLs in the en-US child | 14,821 (under the 50,000 limit) |
| Size of the en-US child | 126,756 bytes gzipped, 1,936,521 bytes unpacked (under 50 MB) |
| Parses as XML | Yes |
| First 10 URLs with HEAD | all 200 |
| Duplicate entries | 1: `/en-US/blog/` is listed twice |
| Error pages listed | `/en-US/404`, which returns 200 with the title "Page not found" |

**The answer:** the sitemap is valid and nothing is truncated: 10 is the
number of child sitemaps, and the English one alone lists 14,821 pages. A
closer look found two small hygiene issues no status check would catch: a
duplicate entry, and a "page not found" page served with status 200 and
listed for indexing. Google calls that a soft 404. The fix on your own
site: exclude error and utility routes from the generator, and de-duplicate
before writing the file.

## How to read the results

| What you see | What it means |
| --- | --- |
| **Sitemap found** | The sitemap returned 200 and contains `<urlset>` or `<sitemapindex>`. Green with no broken samples; amber when a sample failed. |
| **No sitemap** | Nothing valid at `/sitemap.xml`, `/sitemap_index.xml`, `/sitemap/sitemap.xml` or the first `Sitemap:` line in `robots.txt`. |
| **URLs** | The number of `<loc>` entries in that file: pages for a `<urlset>`, child sitemaps for a `<sitemapindex>`. |
| **Sampled** | The first 5 entries, requested with HEAD and following redirects. |
| **Broken** | Sampled entries that ended in 4xx or 5xx, or failed to connect. |
| **Broken links** | Each failing URL with its status code. |

Redirects that end in 200 count as working here. For your own sitemap, list
the final URL anyway: Google asks for the canonical URLs you want to see in
search results, and a redirecting entry is not one.

## More ways to use it

- **After a URL restructure.** Old paths that now redirect should leave the
  sitemap; put a few of them at the top and see whether they still appear.
- **After switching generators.** A new plugin may change the format from a
  single `<urlset>` to an index, or forget the `xmlns` namespace.
- **When pages show as "Excluded" in Search Console.** Check whether the
  sitemap lists URLs that are redirected, `noindex` or error pages.
- **Before submitting to Search Console.** Confirm the file returns 200 to
  an outside request, not only from your build machine.

## Tips and gotchas

- **The validator doesn't open child sitemaps.** For an index, open a child
  with curl (below), or point a monitor at the child sitemap's URL.
- **It checks status, not content.** A soft 404 like MDN's `/en-US/404`
  answers 200 and passes. Scan your sitemap for paths like `404`, `search`,
  `login` or `cart`.
- **Only the first five entries are requested.** Sitemaps are often sorted,
  so "0 broken" says little about the end of the file.
- **Gzipped children are normal.** `.xml.gz` is allowed by the protocol,
  and the limits apply to the uncompressed size.
- **`lastmod` should be real.** Search engines ignore a `lastmod` that
  changes on every build. Set it from the page's actual modification date.
- **Encoding matters.** URLs must be absolute, on the same host as the
  sitemap, and XML-escaped (`&amp;` instead of `&`).

## Check it from the command line too

List the child sitemaps in the index:

```bash
curl -s https://developer.mozilla.org/sitemap.xml | grep -o '<loc>[^<]*</loc>' | head -3
curl -s https://developer.mozilla.org/sitemap.xml | grep -o '<sitemap>' | wc -l
```

```text
<loc>https://developer.mozilla.org/sitemaps/en-us/sitemap.xml.gz</loc>
<loc>https://developer.mozilla.org/sitemaps/es/sitemap.xml.gz</loc>
<loc>https://developer.mozilla.org/sitemaps/fr/sitemap.xml.gz</loc>
10
```

Unpack one child, count its URLs, check it parses, and find duplicates:

```bash
curl -s https://developer.mozilla.org/sitemaps/en-us/sitemap.xml.gz | gunzip > en-us.xml
grep -o '<loc>' en-us.xml | wc -l
python3 -c "import xml.dom.minidom as m; m.parse('en-us.xml'); print('well-formed')"
grep -o '<loc>[^<]*</loc>' en-us.xml | sort | uniq -d
```

```text
14821
well-formed
<loc>https://developer.mozilla.org/en-US/blog/</loc>
```

Then request the first entries the way a crawler would:

```bash
grep -o '<loc>[^<]*</loc>' en-us.xml | sed 's/<[^>]*>//g' | head -10 \
  | while read -r u; do echo "$(curl -s -o /dev/null -w '%{http_code}' -I "$u") $u"; done
```

```text
200 https://developer.mozilla.org/en-US/
200 https://developer.mozilla.org/en-US/404
200 https://developer.mozilla.org/en-US/about
...
```

`curl -s https://developer.mozilla.org/en-US/404 | grep -o '<title>[^<]*</title>'`
prints `<title>Page not found | MDN</title>`: the soft 404 from the table.

## Keep watching it

A sitemap that validates today can be emptied by tomorrow's deploy. A
[sitemap monitor](/sitemap-monitoring) re-checks it on a schedule, samples
up to 50 entries from the top, and alerts on a missing sitemap, a broken-URL
ratio above your threshold, or a URL count that drops below a minimum. For
an index, add a monitor per child sitemap you care about, since children
are sampled, not opened.

## FAQ

**How do I check if my sitemap is valid?**
Open it in a browser or with curl and confirm it returns 200 and XML that
starts with `<urlset>` or `<sitemapindex>`, then check that the listed URLs
return 200. The free validator does the first part and samples the entries.

**How many URLs can a sitemap have?**
50,000 URLs and 50 MB uncompressed per file. Larger sites split the list
into several files and list them in a sitemap index, as MDN does.

**Should a sitemap include redirected or 404 pages?**
No. List only canonical URLs that return 200 and that you want indexed.
Redirects, error pages and `noindex` pages spend crawl time on URLs that
won't be indexed and clutter Search Console's reports. The
[404 guide](/blog/404-not-found) covers soft 404s.

---

Canonical page: https://watchfor.io/blog/how-to-validate-an-xml-sitemap · All articles: https://watchfor.io/blog/all.md · Site guide: https://watchfor.io/llms.txt
