Skip to main content

Fix Sitemap File Size Error: When 50MB Hits Before 50,000 URLs

A sitemap file size error means the file is over 50MB uncompressed, and gzip won't fix it. At 10 hreflang links per URL, that's 35,412 URLs. How to split it.

• • 8 min read
Dashboard cover for a post on fixing the Search Console sitemap file size error: measure the uncompressed bytes and URL count, split the file under both limits, list the parts in a sitemap index, and resubmit the index

TL;DR — A sitemap file size error is Search Console telling you one sitemap is over 50MB uncompressed, and its twin, Too many URLs, means it lists more than 50,000 URLs. I generated test sitemaps in five shapes and found that plain <loc> entries hit the 50,000 cap first, while 10 or more hreflang links per URL hit 50MB first, at 35,412 URLs. Gzip never fixes either, because Google measures the uncompressed bytes, so the fix is to split the file under both limits and submit one sitemap index.

Most guides treat these as one error with one number. They’re two limits measured two ways, and which one you trip depends on what’s inside each <url> block. That’s why a sitemap with 30,000 URLs can fail while one with 49,000 passes.

What Does the Sitemap File Size Error Mean?

It means Google downloaded your sitemap, unpacked it, and the result was larger than 50MB. Google’s Sitemaps report help lists it as Sitemap file size error: Your sitemap exceeds the maximum file size limit, explained as “Your sitemap is larger than 50MB when uncompressed.” The fix it gives is to split the file and list the parts in a sitemap index.

Both numbers come from the sitemaps.org protocol. A sitemap “must have no more than 50,000 URLs and must be no larger than 50MB (52,428,800 bytes).” The same caps apply to a sitemap index: no more than 50,000 sitemaps and no larger than 50MB.

Search Console reports each limit under its own name, plus one structural error people run into while fixing the first two:

Error in the Sitemaps reportWhat tripped itFix
Sitemap file size errorOver 50MB uncompressedSplit by bytes, list parts in an index
Too many URLsMore than 50,000 <url> entriesSplit by count, list parts in an index
Too many sitemapsIndex lists more than 50,000 sitemapsUse several indexes, submit each
Nested sitemap indexesAn index lists another indexPoint the index at sitemap files only
Compression errorThe .gz file won’t decompressRecompress with gzip and resubmit

The first two errors have the same cure, so the splitter below handles both at once.

Which Limit Does Your Sitemap Hit First?

I wrote a Node script that builds a 50,000-URL sitemap in five shapes, using realistic product URLs about 80 characters long. It measures the uncompressed bytes per <url> entry and works out how many URLs fit in 52,428,800 bytes. I also measured this site’s live blog-sitemap.xml on December 6, 2026.

Sitemap shapeBytes per URLURLs that fit in 50MBLimit you hit first
<loc> + <lastmod> only146358,09350,000 URLs
5 <image:image> per URL64581,24650,000 URLs
umesh-malik.com blog sitemap (live)1,74530,03750MB
10 hreflang links per URL1,48135,41250MB
20 hreflang links per URL2,81518,62750MB

A plain sitemap at the full 50,000 URLs weighs just 7MB. You’d need seven times more URLs before the byte limit mattered, so for most sites Too many URLs is the only one you’ll see.

International sites are different. Every xhtml:link alternate repeats a full URL, so 10 languages makes each entry ten times heavier. At 20 languages, a file breaks the size limit at 18,627 URLs. Count-only splitting tools miss this and write 50,000-URL files that fail anyway.

The surprise was my own sitemap. Each post carries <image:title> and <image:caption> copied from long alt text, and those two tags are 63.7% of the file’s bytes. Google’s image sitemap docs say it removed <image:caption>, <image:title>, <image:geo_location> and <image:license> from its documentation. Without them, the same entries drop to 633 bytes and the 50MB ceiling moves out to 82,765 URLs. At 214 posts it doesn’t matter yet, but it’s dead weight worth trimming before it does.

Bar chart of how many URLs fit in a 50MB sitemap for five shapes. Plain loc and lastmod fits 358,093 URLs and 5 images per URL fits 81,246, so both hit the 50,000 URL cap first. The live umesh-malik.com blog sitemap fits 30,037, 10 hreflang links per URL fits 35,412 and 20 hreflang links fits 18,627, so all three hit the 50MB byte limit first

Why Doesn’t Gzip Fix a Sitemap That’s Too Large?

Because the limit is measured after Google decompresses the file. The protocol says you “may compress your Sitemap files using gzip,” but “the sitemap file once uncompressed must be no larger than 50MB.” Gzip saves bandwidth on the download. It doesn’t change what Google counts.

Sitemaps compress extremely well because every entry repeats the same tags and URL prefix. My 50,000-URL test with 10 hreflang links per URL was 70.6MB raw and 2.02MB gzipped, a 35× ratio. Search Console still rejects it, because 70.6MB is over the limit. The real blog sitemap compresses about 13.6×, from 373,519 bytes to 27,504.

That gap is how this error survives reviews. Someone checks the file on the CDN, sees a 2MB .xml.gz, and closes the ticket. Always measure the uncompressed size:

Bash
# Works on .xml and .xml.gz alike: zcat -f passes plain files through untouched
curl -s https://www.example.com/sitemap.xml.gz | zcat -f | wc -c            # must be ≤ 52428800
curl -s https://www.example.com/sitemap.xml.gz | zcat -f | grep -o '<loc>' | wc -l   # must be ≤ 50000

If a sitemap is served with Content-Encoding: gzip by the web server, curl without --compressed already gets the raw bytes and zcat -f handles them too.

Diagram of the gzip trap. A 70.6MB sitemap compresses 35 times to a 2.02MB gzip file on the server, which looks small on the CDN. Google decompresses it back to 70.6MB, checks it against the 50MB limit, and reports a sitemap file size error. The fix shown is splitting the uncompressed file, not compressing it harder

A Script That Splits a Sitemap Under Both Limits

This splitter reads one oversized <urlset>, keeps its namespace declarations, and starts a new file whenever the next entry would cross either budget. It leaves 10% headroom, at 45,000 URLs and 45MB, so a few new pages don’t push a file back over. Then it writes a sitemap index that lists every part. It needs Node 18+ and no dependencies.

JavaScript
// split-sitemap.mjs — node split-sitemap.mjs <big-sitemap.xml> <out-dir> <public-base-url>
import { readFileSync, writeFileSync, mkdirSync } from 'node:fs';

const MAX_URLS = 45000;               // headroom under the 50,000 hard cap
const MAX_BYTES = 45 * 1024 * 1024;   // headroom under 52,428,800 bytes, uncompressed

const [src, outDir, base] = process.argv.slice(2);
const xml = readFileSync(src, 'utf8');
const head = xml.slice(0, xml.indexOf('<url>'));   // keeps every xmlns declaration
const tail = '</urlset>\n';
const urls = xml.match(/<url>[sS]*?</url>/g) ?? [];
const overhead = Buffer.byteLength(head + tail);

mkdirSync(outDir, { recursive: true });
const files = [];
let chunk = [], bytes = 0;
const flush = () => {
  if (!chunk.length) return;
  const name = `sitemap-${files.length + 1}.xml`;
  writeFileSync(`${outDir}/${name}`, head + chunk.join('\n') + '\n' + tail);
  files.push({ name, urls: chunk.length, bytes: overhead + bytes });
  chunk = []; bytes = 0;
};
for (const u of urls) {
  const b = Buffer.byteLength(u) + 1;
  if (chunk.length >= MAX_URLS || overhead + bytes + b > MAX_BYTES) flush();
  chunk.push(u); bytes += b;
}
flush();

const now = new Date().toISOString();
writeFileSync(`${outDir}/sitemap-index.xml`,
  '<?xml version="1.0" encoding="UTF-8"?>\n'
  + '<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">\n'
  + files.map((f) => `  <sitemap><loc>${base}/${f.name}</loc><lastmod>${now}</lastmod></sitemap>`).join('\n')
  + '\n</sitemapindex>\n');
for (const f of files) console.log(`${f.name}  ${f.urls} URLs  ${(f.bytes / 1048576).toFixed(1)} MB`);
console.log(`sitemap-index.xml  ${files.length} sitemaps  (${urls.length} URLs total)`);

I ran it on a 338MB test sitemap with 120,000 URLs and 20 hreflang links each. A count-only splitter would write three files of about 135MB, and all three would fail. This one split on bytes instead and finished in 2.3 seconds:

Text
sitemap-1.xml  16819 URLs  45.0 MB
sitemap-2.xml  16736 URLs  45.0 MB
...
sitemap-7.xml  16613 URLs  45.0 MB
sitemap-8.xml  2892 URLs  7.8 MB
sitemap-index.xml  8 sitemaps  (120000 URLs total)

The same 120,000 URLs without hreflang split on count: three files of 45,000, 45,000 and 30,000 URLs at 6.3MB, 6.3MB and 4.2MB.

The regex parse is fine for sitemaps your own code generated. For a hand-edited file with CDATA or comments, swap in a streaming XML parser. Better still, fix the generator so it never writes an oversized file in the first place.

How to Fix the Sitemap File Size Error in 6 Steps

  1. Measure the failing file uncompressed. Run the two zcat -f commands above against the exact URL in the Sitemaps report. You now know which limit you hit and by how much.

  2. Cut dead weight first. Drop <image:title>, <image:caption>, <changefreq> and <priority>, which Google ignores. Strip pretty-printing whitespace. That alone can bring a borderline file under 50MB without changing your URL structure.

  3. Split under both limits, with headroom. Use the script above, or set your generator’s per-file cap by bytes as well as count. Keep each file at or under 45,000 URLs and 45MB so growth doesn’t re-break it next month.

  4. Keep every child sitemap at or below the index’s folder. Google’s large sitemaps guide says referenced sitemaps “must be in the same directory as the sitemap index file, or lower in the site hierarchy.” Put the index and the parts at the root, or every child can fail with URL not allowed.

  5. Never put an index inside an index. If you have more than 50,000 child sitemaps, write several indexes and submit each one. Google allows up to 500 sitemap index files per site in Search Console.

  6. Delete the old entry and submit only the index. In the Sitemaps report, remove the oversized sitemap, then submit sitemap-index.xml. Update the Sitemap: line in robots.txt to the index too. Each child then appears in the report with its own discovered URL count.

Give each child an accurate <lastmod> in the index, set to the newest change in that file, not the build time. A build timestamp on every child teaches Google to ignore the field, which is the problem covered in fixing sitemap lastmod dates.

Architecture of the fixed setup. One sitemap-index.xml at the site root lists eight child sitemaps, each at or under 45,000 URLs and 45MB uncompressed. Only the index is submitted in Search Console and named in robots.txt, and Google fetches each child from it. An index nested inside another index is crossed out as not allowed

What Breaks If You Ignore It?

Search Console marks the whole file as an error, and Google doesn’t document reading the first 50,000 URLs or the first 50MB of an oversized file. Treat every URL in it as unsubmitted until the split files show Success, not just the ones past the cap. Pages with strong internal links will still be crawled. New or deep pages that only the sitemap points at are the ones that stall in Discovered – currently not indexed.

International sites get hit twice. The hreflang alternates that inflate the file are also how Google pairs your language versions. If the file fails, those pairings go unread, and you can end up with the symptoms in hreflang no return tags without a single wrong tag.

Once the split sitemaps show Success, check the neighbouring errors in this series: Couldn’t fetch and Sitemap appears to be an HTML page. The rest of the technical SEO guides are in the AI search hub.

FAQ

What is the maximum size of a sitemap?

50,000 URLs or 50MB (52,428,800 bytes) uncompressed, whichever comes first. A sitemap index has the same caps, counted in sitemaps instead of URLs.

Does gzip compression fix the sitemap file size error?

No. Google measures the file after decompressing it. Gzip saves bandwidth, but only splitting the file fixes the error.

Can a sitemap index list another sitemap index?

No. That’s the Nested sitemap indexes error. Use several indexes and submit each one, up to 500 per site.

Do hreflang and image tags count toward the sitemap size limit?

Yes, every byte counts. With 10 hreflang links per URL, my test sitemap passed 50MB at 35,412 URLs.

Should I resubmit every child sitemap after splitting?

No. Submit only the index and delete the old oversized entry. Google fetches the children from the index.

Sources

  • Google Search Console Help, Manage your sitemaps using the Sitemaps report: exact wording of Sitemap file size error, Too many URLs, Too many sitemaps, Nested sitemap indexes and Compression error.
  • sitemaps.org, Sitemaps XML format: the 50,000 URL and 52,428,800 byte limits, gzip measured uncompressed, and the same caps for sitemap index files.
  • Google Search Central, Manage your sitemaps with a sitemap index file: child sitemaps at or below the index’s folder, no nested indexes, and 500 index files per site.
  • Google Search Central, Image sitemaps: the removed image:title, image:caption, image:geo_location and image:license tags.
  • First-party test: generated 50,000-URL sitemaps in five shapes, a 120,000-URL split run, and umesh-malik.com’s live blog-sitemap.xml, measured December 6, 2026.

Frequently asked questions

Share this article:
X LinkedIn

Google Search · Preferred sources

Prefer this site on Google

If you already read this writing, add umesh-malik.com as a Preferred Source. Google can then highlight it with a preferred badge in Top Stories, AI Overviews, and AI Mode — for you, not as a site-wide ranking boost.

Keep reading

Get new posts on AI, Claude Code & LLMs

New deep-dives on AI engineering, Claude Code, and developer tooling — follow along however you prefer.