Technical SEO & Indexing • 12 min read

How to Validate an XML Sitemap and Fix Errors Before Submitting It

Validate your XML sitemap before submitting it. Catch syntax errors, unescaped characters and bad dates with a free validator, before Google rejects the file.

By SEO Free Editorial Team
Published: November 22, 2026
XML sitemap validator guide — syntax, namespace and date checks on SEO Free

A sitemap is the simplest map you can hand a search engine: a list of your pages, in a format it can read in seconds. But the whole idea only works if the file itself is readable. A single unescaped ampersand, one missing closing tag, or a date written the wrong way round is enough for Google Search Console to answer with "Sitemap couldn't be read" — and when that happens, Googlebot stops processing the file entirely. Your new pages sit undiscovered, not because they are bad pages, but because the map that was supposed to point at them was broken.

The fix is cheap: validate the sitemap before you submit it. This guide shows you how to do that with a free XML Sitemap Validator, what the tool actually checks, how to read its report, and how to fix every error it finds — so the file you submit to Search Console is clean the first time.

What sitemap validation actually checks

Validation is not a ranking check and it is not a crawl test. It answers one narrow question: is this file well-formed, standards-compliant XML that a search engine parser can read? The validator on SEO Free inspects the file against the official sitemaps.org 0.9 schema and the W3C XML rules, using the same kind of parsing a search engine performs.

Concretely, it checks five things. First, XML syntax: every tag opened must be closed, brackets must match, and no illegal character may appear where the parser does not expect one. A single stray character can make the whole document unreadable — parsers do not skip the broken line and carry on; they stop. Second, the namespace declaration: the root element must carry xmlns="http://www.sitemaps.org/schemas/sitemap/0.9", on a <urlset> for a normal sitemap or a <sitemapindex> for an index file. Without it, the file is XML, but it is not a sitemap. Third, date formatting: every <lastmod> value must follow the W3C Datetime format — 2026-11-22, or with a time, 2026-11-22T09:00:00+00:00. A date written as 11/22/2026 is invalid. Fourth, escaping: the characters &, <, >, " and ' have special meaning in XML, so inside a URL they must be written as &amp;, &lt;, &gt;, &quot; and &apos;. A raw & in a tracking query string — the most common real-world mistake — breaks the parse. Fifth, size and structure limits: a sitemap may hold at most 50,000 URLs and must be under 50 MB uncompressed. Anything bigger must be split behind a sitemap index.

Two more checks round the report out. The validator flags soft warnings — things that do not stop parsing but signal sloppy generation, such as a <lastmod> dated in the future, an unusually long URL, or a <priority> outside the 0.0–1.0 range. And it checks the host form of the URLs: if your pages canonicalize to the non-www version but every <loc> entry uses www — or the file still lists http:// URLs after an HTTPS migration — you are feeding search engines a list of redirects instead of final destinations.

Hard errors vs. soft warnings: read the report in the right order

Not every finding carries the same weight, and fixing them in the wrong order wastes time. Hard errors — malformed XML, a missing <urlset> root element, broken date syntax — mean parsers cannot read the file at all. Fix every hard error first, because nothing else in the report can be trusted until the file parses. A validator cannot reliably judge the URLs inside a document it cannot read, so warnings reported alongside a hard error may vanish once the syntax is fixed.

Soft warnings come second. A future-dated <lastmod>, usually from a server clock error, will not stop the file from being processed, but it confuses crawl scheduling: Google may decide the page has not changed when it has, or treat the date as unreliable and ignore it. A <priority> of 1.5 is simply out of range and gets ignored. Fix these while you are editing anyway, but do not let a clean warning list distract you from a hard error — a file with zero warnings and one hard error is still unreadable.

How to validate your XML sitemap in 6 steps

The validator accepts two inputs: raw XML pasted directly, or a public sitemap URL. Paste is the more reliable route when you are testing a file before it goes live, because it checks exactly the text you give it. Follow these steps:

  1. Open the validator and choose your input. Go to the XML Sitemap Validator. If your sitemap is already live, you can enter its public URL. If you are testing a file that is not published yet — or a local or staging copy — paste the raw XML into the input box instead. The tool also offers a Load Sample XML button if you want to see what a report looks like before testing your own file.
  2. Click "Validate XML Sitemap". The engine parses the XML, verifies the namespace, and inspects syntax, URL formatting, date stamps and size limits. The check is instant for normal files; very large sitemaps take a few seconds longer.
  3. Read the pass/fail status first, then the details. A clean report means the file is well-formed and schema-compliant. If it fails, the report names the exact line and the error description — for example, an unescaped ampersand on line 42, or a missing closing </urlset> tag. Fix the reported errors in the order the report lists them, starting with the first one: one syntax error early in the file can produce a cascade of misleading errors further down.
  4. Fix every hard error, then re-validate the corrected file. Edit your source file — the CMS plugin, the generator output, or the hand-written XML — not a copy of the report. Then paste the corrected XML back in and validate again. Repeat until the report is clean. Never submit a file you fixed but did not re-validate: it is easy to introduce a new typo while repairing the old one.
  5. If your file is a sitemap index, validate every child. A clean result on an index only proves the index itself is well-formed. Each child sitemap it references is a separate file with its own chance of carrying a syntax slip or a stale URL. Validate every child individually, starting with the most recently regenerated ones. One broken child can quietly leave a whole site section undiscovered while the index itself reports success.
  6. Check the host and the delivery, then submit. Before uploading, compare a sample of validated URLs against the canonical tags on the live pages — the host form must match (www vs. non-www, http vs. https). Then upload the file and submit it in Search Console. If you are building a sitemap from scratch rather than fixing one, the XML Sitemap Generator produces a standards-compliant file you can validate the same way, and our guide to generate and submit an XML sitemap walks through the submission step itself.

Common sitemap errors and how to fix each one

Most validation failures come from a short list of mistakes. Here is what each one looks like and what to do about it.

Unescaped ampersands in URLs

This is the single most common error. A URL such as https://example.com/page?utm_source=google&utm_medium=cpc is fine in a browser, but in XML the raw & starts an entity reference that never closes, and the parser fails. Write it as &amp; instead. Better still, strip tracking parameters from sitemap URLs entirely — they add nothing for a crawler and only create escaping risk.

Missing closing tags

A file that ends without </urlset> (or </sitemapindex> for an index) is truncated XML, and no parser will accept it. This usually happens when a generator crashes mid-write, a file is cut off during upload, or a hand edit deletes a line by accident. Re-generate the file rather than patching the tail by hand, so you know the rest of the content is complete too.

Wrong date formats

<lastmod> must be YYYY-MM-DD or a full W3C datetime such as 2026-11-22T09:00:00+00:00. Regional formats like 11/22/2026 or 22-11-2026 are invalid and will be flagged. If your CMS writes dates in a local format, change its sitemap template to output ISO 8601 — do not fix dates by hand in every file.

Missing or wrong namespace

A sitemap without xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" on its root element is not recognized as a sitemap at all, even if every URL inside it is perfect. Check the opening tag of the file first whenever a validator reports a namespace error — generators that build XML by string concatenation sometimes drop the attribute.

URLs that do not match the canonical host

Validation passes, but the file still works against you. If the site canonicalizes to https://example.com and the sitemap lists https://www.example.com, every entry is a redirect. Search engines will follow some of them, but you have wasted crawl budget and sent a confusing signal. Generate the sitemap from the same base URL your canonical tags use.

Validating the index but never the children

A sitemap index is a table of contents, not the content. Real-world example: the index passes cleanly, but checking the children reveals that sitemap-blog.xml sets a <lastmod> of 2027-03-15 — a future date from a server clock error — and sitemap-products.xml still lists http:// URLs although the site migrated to HTTPS last year. Both children get fixed and re-validated before the index is submitted. Make child validation part of the routine, not an afterthought.

The file passes validation but Search Console still errors

This is the most confusing case, and it has a simple explanation: the validator checks the XML you paste, not the copy your server actually delivers. If the file is valid but Search Console reports "Sitemap couldn't be read" or a "General HTTP error", the problem is delivery, not syntax. Check that the server returns the file with an XML content type instead of HTML, that a CDN is not serving a stale cached copy, and that no firewall or robots.txt rule blocks Google's fetcher — a robots.txt rule such as Disallow: /sitemap.xml will stop search engines reading the file at all. Compare the live file, byte for byte, against the version you validated.

Tips for keeping sitemaps valid over time

  • Validate before every submission. Validate before the initial Search Console submission and again whenever you deploy CMS structural updates, change a sitemap plugin, or regenerate the file. A plugin update can silently change the output format.
  • Validate staging copies by pasting. You do not need a public URL to validate. Paste raw XML from a local or staging sitemap and catch errors before the file ever reaches production.
  • Watch the 50,000-URL and 50 MB limits. A growing site crosses these quietly. Split oversized sitemaps with an index before the file is rejected, and validate each child after the split. Gzip compression is accepted — a sitemap.xml.gz file is fine — but decompress it first if you want to paste its contents into the validator.
  • Keep <lastmod> honest. Only update the date when the page actually changed. A file that stamps every URL with today's date on every regeneration teaches search engines to ignore the field, and a future date from a wrong server clock does the same.
  • Re-validate after every fix. Fixing one error can introduce another, especially when editing XML by hand. The loop is: fix, re-validate, repeat until clean, then submit.

Frequently asked questions

Why does Google Search Console show "Sitemap couldn't be read"?

This usually stems from XML syntax errors, missing namespace declarations, unescaped characters, server timeouts, or the server returning HTML instead of XML. Validate the file first: if the validator reports hard errors, fix those. If it passes, check delivery — content type, CDN caching, and whether robots.txt or a firewall blocks Google's fetcher.

Can a sitemap contain both pages and other sitemaps?

No. A sitemap must either be a standard URL set (<urlset>) or a sitemap index (<sitemapindex>) referencing child sitemaps, never a mixture of both. Mixing the two is a schema violation and will fail validation.

What is the maximum allowed size of a sitemap?

50 MB uncompressed and 50,000 URLs. If your file exceeds either limit, split it using a sitemap index and validate each child file separately. Gzip-compressed sitemaps (sitemap.xml.gz) are accepted by search engines.

How do I validate a sitemap.xml.gz file?

Download the .gz file and decompress it first — tools like 7-Zip or the gzip command-line utility extract the plain XML inside. Paste that XML into the validator exactly as you would an uncompressed sitemap; the checks are identical.

My sitemap passes validation, so why does Search Console still show an error?

The XML is likely fine, so check delivery instead. The server may send an HTML content type, a CDN may serve a stale copy, or a firewall may block Google's fetcher. Compare the live file against the version you validated, and check that robots.txt does not disallow the sitemap path.

Bottom line

A sitemap is only useful if a parser can read it, and a parser is unforgiving: one unescaped character or one missing tag invalidates the whole file. Validate before you submit, fix hard errors before soft warnings, re-validate after every fix, and validate each child of an index separately. It takes two minutes, it costs nothing, and it is the difference between a sitemap that gets your pages discovered and one that Search Console quietly refuses to read.

Validate Your Robots.txt Directives in Bulk

Test up to 100 paths simultaneously against your live or draft rules using our RFC 9309 compliant evaluation engine.

Open Bulk Robots.txt Tester

Related Technical Guides