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.

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 report | What tripped it | Fix |
|---|---|---|
| Sitemap file size error | Over 50MB uncompressed | Split by bytes, list parts in an index |
| Too many URLs | More than 50,000 <url> entries | Split by count, list parts in an index |
| Too many sitemaps | Index lists more than 50,000 sitemaps | Use several indexes, submit each |
| Nested sitemap indexes | An index lists another index | Point the index at sitemap files only |
| Compression error | The .gz file won’t decompress | Recompress 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 shape | Bytes per URL | URLs that fit in 50MB | Limit you hit first |
|---|---|---|---|
<loc> + <lastmod> only | 146 | 358,093 | 50,000 URLs |
5 <image:image> per URL | 645 | 81,246 | 50,000 URLs |
| umesh-malik.com blog sitemap (live) | 1,745 | 30,037 | 50MB |
| 10 hreflang links per URL | 1,481 | 35,412 | 50MB |
| 20 hreflang links per URL | 2,815 | 18,627 | 50MB |
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.
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:
# 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 ≤ 50000If 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.
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.
// 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:
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
Measure the failing file uncompressed. Run the two
zcat -fcommands above against the exact URL in the Sitemaps report. You now know which limit you hit and by how much.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.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.
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.
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.
Delete the old entry and submit only the index. In the Sitemaps report, remove the oversized sitemap, then submit
sitemap-index.xml. Update theSitemap:line inrobots.txtto 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.
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_locationandimage:licensetags. - 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
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.
Related Articles

Web Engineering
Fix Sitemap URL Not Allowed in Search Console: 11 Cases Tested
Sitemap URL not allowed means a <loc> sits outside the sitemap's host, protocol, port or folder. I ran 11 setups through a checker: 6 fail, 1 needs robots.txt.

Web Engineering
Fix Your Sitemap Appears to Be an HTML Page: 8 Causes Tested
Your sitemap appears to be an HTML page means Google got HTML, not XML. I tested 8 causes. Two hit only Googlebot, so it looks fine in your browser.

Web Engineering
Fix Sitemap Contains URLs Which Are Blocked by Robots.txt: 4 Causes
Sitemap contains URLs which are blocked by robots.txt means your two files disagree. Find the Disallow rule behind each URL, then decide which file is wrong.
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.
About the Author
Software engineer writing about AI, Claude Code, LLMs, OpenAI, Anthropic, and developer tooling. 5+ years building production systems at Expedia Group, Tekion, and BYJU'S.