# Sitemap Extractor, Validator & Generator (`rationalistic_tail/sitemap-validator-generator`) Actor

All-in-one XML sitemap tool: extract every URL from a site's sitemaps (auto-discovered, indexes, .gz), validate against sitemaps.org and Google rules (lastmod, duplicates, 50k limit, robots-blocked, 404, noindex, canonical), or crawl a site politely to generate sitemap.xml. AI-ready summary.

- **URL**: https://apify.com/rationalistic_tail/sitemap-validator-generator.md
- **Developed by:** [Jerry Lin](https://apify.com/rationalistic_tail) (community)
- **Categories:** SEO tools, Developer tools, Agents
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.30 / 1,000 sitemap url listeds

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

### What does Sitemap Extractor, Validator & Generator do?

One Actor for everything **XML sitemap**: give it a website (e.g. `https://example.com`) and choose a mode.

| Mode | What you get |
|---|---|
| 📥 **extract** | Every URL from the site's sitemaps with `lastmod`, `changefreq`, `priority`. Sitemaps are **auto-discovered** from `robots.txt` and `/sitemap.xml`; sitemap **indexes**, **.xml.gz** and **.txt** sitemaps are followed. |
| ✅ **validate** | Extraction **plus** a full health check against the sitemaps.org protocol and Google's rules, and optional HTTP checks of the listed pages. Only URLs with issues are listed, with clear issue codes. |
| 🛠️ **generate** | Politely crawls the site and builds a fresh **sitemap.xml** (and sitemap.txt) with only indexable pages – no `noindex`, no non-canonical duplicates, no error pages, no login pages. |

Every run also writes a compact **`OUTPUT_SUMMARY`** with an **`llmSummary`** paragraph – ideal for AI agents and the [Apify MCP server](https://mcp.apify.com).

### What does the validator check?

**Sitemap files**: HTTP errors, unreachable or robots-blocked sitemaps, HTML instead of XML, XML parse errors, wrong root element, missing sitemaps.org namespace, more than **50,000 URLs** or **50 MB**, empty files, nested sitemap indexes, redirecting sitemap URLs, sitemaps **not listed in robots.txt**, no sitemap at all.

**Every URL**: invalid or relative URLs, URLs longer than 2,048 characters, `#fragments`, whitespace, **different host / www / http-vs-https than the sitemap**, **duplicate URLs**, invalid or **future `lastmod`**, invalid `changefreq` and `priority`, and **URLs listed in the sitemap but disallowed by robots.txt** (a classic Search Console warning).

**With HTTP checks** (default on, capped by *Max URLs to HTTP-check*): **404/410**, 5xx, unreachable pages, **redirects** (with final URL), **`noindex`** (meta robots or `X-Robots-Tag`) and **canonical pointing elsewhere** – all of which should not be in a sitemap.

Each row gets `severity` = `error`, `warning` or `ok`.

### Polite and compliant by design

- ✅ **robots.txt always honored** (and its `Crawl-delay`); disallowed URLs are never fetched.
- ✅ **Per-host rate limit** (default 2 requests/s per host, never faster than 4/s) and max 5 parallel requests.
- ✅ **Public pages only** – no login, no cookies, no CAPTCHA solving. Clear User-Agent `SitemapValidatorBot`.
- ✅ Extraction downloads only the sitemap files – not the pages – unless you ask for HTTP checks.

### How to use it

1. Enter your **website or sitemap URL(s)**.
2. Pick **mode**: `extract`, `validate` or `generate`.
3. Adjust limits (*Max sitemap URLs*, *Max URLs to HTTP-check*, *Max pages to crawl*).
4. Click **Start** and open the **Overview** table, `OUTPUT_SUMMARY`, or – in generate mode – download **`SITEMAP_XML`** from the Storage tab.

#### Example input (validate)

```json
{
  "urls": ["https://example.com"],
  "mode": "validate",
  "maxUrls": 10000,
  "checkUrlStatus": true,
  "maxStatusChecks": 300
}
```

#### Example output row

```json
{
  "severity": "error",
  "url": "https://example.com/old-landing",
  "issues": ["not_found"],
  "httpStatus": 404,
  "sitemapUrl": "https://example.com/sitemap-pages.xml",
  "lastmod": "2024-05-02"
}
```

#### Example summary

```json
{
  "totalUrls": 8421,
  "errorRows": 37,
  "warningRows": 112,
  "topIssues": [{ "issue": "redirects", "count": 64 }, { "issue": "not_found", "count": 21 }],
  "llmSummary": "Found 4 sitemap file(s) with 8421 URLs for https://example.com/. 37 URL errors, 112 warnings. Top issues: redirects×64, not_found×21, ..."
}
```

### How much does it cost?

Pay-per-event pricing – no subscription, no separate compute bill:

| Event | Price |
|---|---|
| `url-listed` – one URL read from a sitemap (extract / validate) | **$0.0003** |
| `page-checked` – one page fetched over HTTP (validate HTTP checks, generate crawl) | **$0.001** |
| Actor start (per GB of memory; default 512 MB = 1 event) | **$0.002** |

Examples: extract 10,000 URLs ≈ **$3.00**; validate 1,000 URLs with 200 HTTP checks ≈ **$0.50**; generate a sitemap from 200 pages ≈ **$0.20**. URLs skipped because of robots.txt are free. Cap the cost with *Max sitemap URLs*, *Max URLs to HTTP-check* and *Max pages to crawl*, or set a max cost per run – the Actor stops cleanly at the limit.

### Use it from AI agents (MCP)

```
https://mcp.apify.com?tools=rationalistic_tail/sitemap-validator-generator
```

An agent can ask "list every URL on example.com", "is this sitemap valid?" or "make me a sitemap.xml" and read `OUTPUT_SUMMARY.llmSummary`. Runs with **limited permissions**, so prepaid agent tokens (Apify AGI, x402) work too.

### FAQ

**Does generate mode render JavaScript?** No, it follows links in the server-rendered HTML (up to 5,000 pages). For JS-only sites, provide your framework's route list instead.

**Can I submit the generated sitemap to Google?** Yes – upload `SITEMAP_XML` to your site root and add `Sitemap: https://your-site/sitemap.xml` to robots.txt.

**Gzipped sitemaps?** Yes, `.xml.gz` files are decompressed automatically.

### Other tools by the same developer

- [Broken Link Checker – 404s, Redirects & #Anchors](https://apify.com/rationalistic_tail/broken-link-anchor-checker)
- [Lighthouse Audit & Performance Budgets](https://apify.com/rationalistic_tail/lighthouse-budget-auditor)
- [Website to RSS / Change Monitor](https://apify.com/rationalistic_tail/website-to-rss-monitor)

# Actor input Schema

## `urls` (type: `array`):

Website homepages (sitemaps are auto-discovered from robots.txt and /sitemap.xml) or direct sitemap URLs (.xml, .xml.gz, .txt). In generate mode, the pages to start crawling from.

## `mode` (type: `string`):

extract = list every URL in the sitemaps. validate = extract + protocol checks (lastmod, duplicates, hosts, 50k limit, robots-blocked URLs) + optional HTTP checks. generate = crawl the site and build a new sitemap.xml.

## `maxUrls` (type: `integer`):

extract/validate: stop after this many sitemap URLs (1-100000). Each URL row is one 'url-listed' event.

## `checkUrlStatus` (type: `boolean`):

validate only: fetch up to maxStatusChecks URLs to detect 404/5xx, redirects, noindex and canonical mismatches. Each fetch is one 'page-checked' event.

## `maxStatusChecks` (type: `integer`):

validate only: cap on URLs fetched for status checks (0-5000).

## `maxPagesToCrawl` (type: `integer`):

generate only: maximum same-host pages to crawl (1-5000). Each fetched page is one 'page-checked' event.

## `includeValidRows` (type: `boolean`):

validate only: false (default) = dataset lists only URLs with issues. extract and generate always list every URL.

## `maxConcurrency` (type: `integer`):

Parallel requests (1-5). Requests to one host are always spaced by the delay below.

## `requestDelayMs` (type: `integer`):

Minimum gap between requests to the same host (250-60000 ms). A larger robots.txt Crawl-delay always wins.

## `requestTimeoutSecs` (type: `integer`):

Per-request timeout in seconds (5-120).

## Actor input object example

```json
{
  "urls": [
    "https://docs.apify.com"
  ],
  "mode": "extract",
  "maxUrls": 5000,
  "checkUrlStatus": true,
  "maxStatusChecks": 200,
  "maxPagesToCrawl": 200,
  "includeValidRows": false,
  "maxConcurrency": 2,
  "requestDelayMs": 500,
  "requestTimeoutSecs": 30
}
```

# Actor output Schema

## `urls` (type: `string`):

One row per sitemap URL (extract/validate) or crawled page (generate).

## `summary` (type: `string`):

Sitemap files, issue counts and an llmSummary paragraph for AI agents.

## `sitemapXml` (type: `string`):

generate mode only: the generated sitemap.xml.

## `sitemapTxt` (type: `string`):

generate mode only: plain-text list of URLs.

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "urls": [
        "https://docs.apify.com"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("rationalistic_tail/sitemap-validator-generator").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = { "urls": ["https://docs.apify.com"] }

# Run the Actor and wait for it to finish
run = client.actor("rationalistic_tail/sitemap-validator-generator").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "urls": [
    "https://docs.apify.com"
  ]
}' |
apify call rationalistic_tail/sitemap-validator-generator --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,rationalistic_tail/sitemap-validator-generator"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/IwJHQkcC8Hj1eyz7g/builds/UNYoketEdxekzFGIJ/openapi.json
