# 🔗 Sitemap & Broken Link Checker — Find Dead Links & 404s (`iskoren/sitemap-broken-link-checker`) Actor

Crawl any website or its sitemap and check every link for broken 404s, redirects, and errors — with the source page for each. Perfect for SEO audits and site QA.

- **URL**: https://apify.com/iskoren/sitemap-broken-link-checker.md
- **Developed by:** [Is Koren](https://apify.com/iskoren) (community)
- **Categories:** SEO tools, Developer tools, Automation
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $5.00 / 1,000 results

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/platform/actors/running/actors-in-store#pay-per-event

## What's an Apify Actor?

Actors are a software tools running on the Apify platform, for all kinds of web data extraction and automation use cases.
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.
Actors are written with capital "A".

## 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.
The best way to integrate Actors is as follows.

In JavaScript/TypeScript projects, use official [JavaScript/TypeScript client](https://docs.apify.com/api/client/js.md):

```bash
npm install apify-client
```

In Python projects, use official [Python client library](https://docs.apify.com/api/client/python.md):

```bash
pip install apify-client
```

In shell scripts, use [Apify CLI](https://docs.apify.com/cli/docs.md):

````bash
# MacOS / Linux
curl -fsSL https://apify.com/install-cli.sh | bash
# Windows
irm https://apify.com/install-cli.ps1 | iex
```bash

In AI frameworks, you might use the [Apify MCP server](https://docs.apify.com/platform/integrations/mcp.md).

If your project is in a different language, use the [REST API](https://docs.apify.com/api/v2.md).

For usage examples, see the [API](#api) section below.

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).


# README

## 🔗 Sitemap & Broken Link Checker — Find Dead Links & 404s

Find broken links, dead pages, and 404 errors on any website — fast. This **sitemap & broken link checker** discovers your site's URLs from its `sitemap.xml`, sitemap index files, and `robots.txt`, and/or by crawling internal links, then checks the HTTP status of every link. You get a clean report of broken links (4xx/5xx), redirects (3xx), and OK pages — plus the exact page each link was found on, so SEO and QA teams can fix dead links before users (and search engines) do.

### ✨ What this actor does

- 🗺️ **Sitemap discovery** — reads `/sitemap.xml`, follows sitemap index files, and parses `Sitemap:` lines in `robots.txt`.
- 🕷️ **Internal crawl** — BFS-crawls internal pages from your start URLs and collects every `<a href>` link, remembering where it was found.
- ✅ **Status checking** — verifies each link with a HEAD→GET strategy (`allow_redirects=True`), recording the final HTTP status.
- 🌐 **Internal & external** — optionally checks off-domain (external) links too.
- 🧯 **Crash-proof** — a single bad URL never stops the run; failures are recorded as `error`.

Perfect for **SEO audits**, **website QA**, **content migrations**, and routine **broken link monitoring**.

### 🚀 Quick start

Paste this input and run:

```json
{
  "startUrls": ["https://apify.com"],
  "useSitemap": true,
  "crawlLinks": true,
  "checkExternalLinks": true,
  "maxUrls": 100,
  "proxyConfiguration": { "useApifyProxy": true }
}
````

The actor discovers links from `apify.com`, checks each one, and pushes a row per link to the dataset.

### ⚙️ Input

| Field | Type | Default | Description |
|-------|------|---------|-------------|
| `startUrls` | array | `["https://apify.com"]` | Website(s) to check. URLs are discovered from each site's sitemap and/or by crawling. |
| `useSitemap` | boolean | `true` | Discover URLs from `/sitemap.xml`, sitemap index files, and `robots.txt`. |
| `crawlLinks` | boolean | `true` | Crawl internal pages (same domain, BFS) to discover links and record their source page. |
| `checkExternalLinks` | boolean | `true` | Also check links pointing to other domains. When off, only same-domain links are checked. |
| `maxUrls` | integer | `100` | Total links to check across all start URLs (hard cap, 1–2000). Keeps runs cheap and finite. |
| `proxyConfiguration` | object | `{ "useApifyProxy": true }` | Proxy settings. Apify Proxy is used by default to avoid IP blocks. |

### 📤 Output

One record per checked link:

```json
{
  "url": "https://apify.com/store",
  "statusCode": 200,
  "ok": true,
  "category": "ok",
  "redirectedTo": null,
  "linkType": "internal",
  "foundOn": "https://apify.com",
  "error": null
}
```

A broken link looks like this:

```json
{
  "url": "https://apify.com/this-page-does-not-exist",
  "statusCode": 404,
  "ok": false,
  "category": "broken",
  "redirectedTo": null,
  "linkType": "internal",
  "foundOn": "https://apify.com/blog",
  "error": null
}
```

#### Output fields

| Field | Description |
|-------|-------------|
| `url` | The link that was checked. |
| `statusCode` | Final HTTP status code (after redirects), or `null` if the request failed. |
| `ok` | `true` when the status is below 400. |
| `category` | One of `ok`, `broken` (4xx/5xx), `redirect` (3xx hop occurred), or `error` (request failed). |
| `redirectedTo` | Final URL if the link redirected, otherwise `null`. |
| `linkType` | `internal` (same domain) or `external` (off-domain). |
| `foundOn` | The page where the link was discovered. |
| `error` | Error message if the request failed, otherwise `null`. |

💡 **Tip:** Filter the dataset by `category = "broken"` (or `ok = false`) to get just the dead links, and group by `foundOn` to see which pages need fixing.

### ❓ FAQ

**How do I find only broken links?**
Filter the output where `category` is `broken` or `error`, or where `ok` is `false`. The `foundOn` field tells you which page to fix.

**Does it follow redirects?**
Yes. Links are checked with `allow_redirects=True`. If any redirect hop occurred, `category` is `redirect` and `redirectedTo` holds the final URL.

**What if the site has no sitemap?**
Leave `crawlLinks` enabled. The actor crawls internal pages from your start URLs to discover links even when no sitemap exists. You can also rely on the `Sitemap:` line in `robots.txt`, which is checked automatically.

**Will it check external (off-site) links?**
Yes, when `checkExternalLinks` is `true` (the default). Set it to `false` to limit checks to your own domain.

**How do I keep runs cheap?**
Use `maxUrls` to cap the total number of links checked. The crawl and sitemap discovery both respect this limit.

**Why are some links reported as `error`?**
Some servers reject automated requests, time out, or have DNS/TLS issues. These are recorded as `error` with a message in the `error` field instead of crashing the run.

### 🧪 Tips for best results

- 🎯 Start with a small `maxUrls` (e.g. 30–50) to preview results, then raise it for a full audit.
- 🔁 Schedule the actor to run weekly and monitor the `broken` count over time.
- 🧹 Disable `checkExternalLinks` for faster internal-only QA runs.
- 🌍 Keep Apify Proxy on to reduce the chance of rate limiting or IP blocks.
- 📊 Export to CSV/Excel/JSON from the dataset for sharing with your SEO or content team.

# Actor input Schema

## `startUrls` (type: `array`):

Website(s) to check. The checker discovers URLs from each site's sitemap and/or by crawling its internal pages, then verifies the HTTP status of every link found.

## `useSitemap` (type: `boolean`):

Try to discover URLs from /sitemap.xml (and any sitemap index it points to) and from a Sitemap: line in robots.txt.

## `crawlLinks` (type: `boolean`):

Crawl internal pages (same domain, BFS from each start URL) to discover links, recording the source page where each link was found.

## `checkExternalLinks` (type: `boolean`):

Also check links that point to other domains (external links). When disabled, only same-domain links are checked.

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

Total number of links to check across all start URLs (hard cap). Keeps runs cheap and finite.

## `proxyConfiguration` (type: `object`):

Proxy settings. Uses Apify Proxy by default to avoid IP blocks.

## Actor input object example

```json
{
  "startUrls": [
    "https://apify.com"
  ],
  "useSitemap": true,
  "crawlLinks": true,
  "checkExternalLinks": true,
  "maxUrls": 100,
  "proxyConfiguration": {
    "useApifyProxy": true
  }
}
```

# Actor output Schema

## `results` (type: `string`):

No description

# 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 = {
    "startUrls": [
        "https://apify.com"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("iskoren/sitemap-broken-link-checker").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 = { "startUrls": ["https://apify.com"] }

# Run the Actor and wait for it to finish
run = client.actor("iskoren/sitemap-broken-link-checker").call(run_input=run_input)

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

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

```

## CLI example

```bash
echo '{
  "startUrls": [
    "https://apify.com"
  ]
}' |
apify call iskoren/sitemap-broken-link-checker --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "command": "npx",
            "args": [
                "mcp-remote",
                "https://mcp.apify.com/?tools=iskoren/sitemap-broken-link-checker",
                "--header",
                "Authorization: Bearer <YOUR_API_TOKEN>"
            ]
        }
    }
}

```

## OpenAPI specification

```json
{
    "openapi": "3.0.1",
    "info": {
        "title": "🔗 Sitemap & Broken Link Checker — Find Dead Links & 404s",
        "description": "Crawl any website or its sitemap and check every link for broken 404s, redirects, and errors — with the source page for each. Perfect for SEO audits and site QA.",
        "version": "0.1",
        "x-build-id": "Wh1gW3g24psL8V2dY"
    },
    "servers": [
        {
            "url": "https://api.apify.com/v2"
        }
    ],
    "paths": {
        "/acts/iskoren~sitemap-broken-link-checker/run-sync-get-dataset-items": {
            "post": {
                "operationId": "run-sync-get-dataset-items-iskoren-sitemap-broken-link-checker",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for its completion, and returns Actor's dataset items in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        },
        "/acts/iskoren~sitemap-broken-link-checker/runs": {
            "post": {
                "operationId": "runs-sync-iskoren-sitemap-broken-link-checker",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor and returns information about the initiated run in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/runsResponseSchema"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/acts/iskoren~sitemap-broken-link-checker/run-sync": {
            "post": {
                "operationId": "run-sync-iskoren-sitemap-broken-link-checker",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for completion, and returns the OUTPUT from Key-value store in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        }
    },
    "components": {
        "schemas": {
            "inputSchema": {
                "type": "object",
                "required": [
                    "startUrls"
                ],
                "properties": {
                    "startUrls": {
                        "title": "Start URLs",
                        "type": "array",
                        "description": "Website(s) to check. The checker discovers URLs from each site's sitemap and/or by crawling its internal pages, then verifies the HTTP status of every link found.",
                        "default": [
                            "https://apify.com"
                        ],
                        "items": {
                            "type": "string"
                        }
                    },
                    "useSitemap": {
                        "title": "Use sitemap",
                        "type": "boolean",
                        "description": "Try to discover URLs from /sitemap.xml (and any sitemap index it points to) and from a Sitemap: line in robots.txt.",
                        "default": true
                    },
                    "crawlLinks": {
                        "title": "Crawl internal links",
                        "type": "boolean",
                        "description": "Crawl internal pages (same domain, BFS from each start URL) to discover links, recording the source page where each link was found.",
                        "default": true
                    },
                    "checkExternalLinks": {
                        "title": "Check external links",
                        "type": "boolean",
                        "description": "Also check links that point to other domains (external links). When disabled, only same-domain links are checked.",
                        "default": true
                    },
                    "maxUrls": {
                        "title": "Max URLs to check",
                        "minimum": 1,
                        "maximum": 2000,
                        "type": "integer",
                        "description": "Total number of links to check across all start URLs (hard cap). Keeps runs cheap and finite.",
                        "default": 100
                    },
                    "proxyConfiguration": {
                        "title": "Proxy configuration",
                        "type": "object",
                        "description": "Proxy settings. Uses Apify Proxy by default to avoid IP blocks.",
                        "default": {
                            "useApifyProxy": true
                        }
                    }
                }
            },
            "runsResponseSchema": {
                "type": "object",
                "properties": {
                    "data": {
                        "type": "object",
                        "properties": {
                            "id": {
                                "type": "string"
                            },
                            "actId": {
                                "type": "string"
                            },
                            "userId": {
                                "type": "string"
                            },
                            "startedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "finishedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "status": {
                                "type": "string",
                                "example": "READY"
                            },
                            "meta": {
                                "type": "object",
                                "properties": {
                                    "origin": {
                                        "type": "string",
                                        "example": "API"
                                    },
                                    "userAgent": {
                                        "type": "string"
                                    }
                                }
                            },
                            "stats": {
                                "type": "object",
                                "properties": {
                                    "inputBodyLen": {
                                        "type": "integer",
                                        "example": 2000
                                    },
                                    "rebootCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "restartCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "resurrectCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "computeUnits": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "options": {
                                "type": "object",
                                "properties": {
                                    "build": {
                                        "type": "string",
                                        "example": "latest"
                                    },
                                    "timeoutSecs": {
                                        "type": "integer",
                                        "example": 300
                                    },
                                    "memoryMbytes": {
                                        "type": "integer",
                                        "example": 1024
                                    },
                                    "diskMbytes": {
                                        "type": "integer",
                                        "example": 2048
                                    }
                                }
                            },
                            "buildId": {
                                "type": "string"
                            },
                            "defaultKeyValueStoreId": {
                                "type": "string"
                            },
                            "defaultDatasetId": {
                                "type": "string"
                            },
                            "defaultRequestQueueId": {
                                "type": "string"
                            },
                            "buildNumber": {
                                "type": "string",
                                "example": "1.0.0"
                            },
                            "containerUrl": {
                                "type": "string"
                            },
                            "usage": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "integer",
                                        "example": 1
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "usageTotalUsd": {
                                "type": "number",
                                "example": 0.00005
                            },
                            "usageUsd": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "number",
                                        "example": 0.00005
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
```
