# Heading Structure Analyzer (`zerobreak/heading-structure-analyzer`) Actor

Heading structure analyzer that pulls H1-H6 tags from any URL, flags missing headings, duplicate H1s, and skipped levels, so SEO teams can fix hierarchy problems before rankings drop.

- **URL**: https://apify.com/zerobreak/heading-structure-analyzer.md
- **Developed by:** [ZeroBreak](https://apify.com/zerobreak) (community)
- **Categories:** SEO tools
- **Stats:** 3 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

$3.99/month + usage

To use this Actor, you pay a monthly rental fee to the developer. The rent is subtracted from your prepaid usage every month after the free trial period.You also pay for the Apify platform usage, which gets cheaper the higher Apify subscription plan you have.

Learn more: https://docs.apify.com/platform/actors/running/actors-in-store#rental-actors

## 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

## Heading Structure Analyzer: Audit H1-H6 Hierarchy on Any Web Page

The heading structure of a page matters for SEO. Google uses heading tags to understand content organization, and common problems like a missing H1, duplicate H1s, or skipped heading levels are easy to fix once you know they exist. Finding them manually across hundreds of pages is not.

This actor fetches any URL, walks the DOM in document order, and returns every heading tag (H1 through H6) with its level, text, and position. It then checks the sequence for structural issues and lists them plainly. Run it on one page or batch-process up to 1,000 URLs in a single run.

### Use cases

- **SEO auditing**: scan an entire site for broken heading hierarchy before publishing or after a CMS migration
- **Content review**: verify that blog posts and landing pages follow a logical H1-H2-H3 outline
- **Technical SEO reports**: pull heading data for all pages into a spreadsheet for client deliverables
- **Pre-publish QA**: check heading structure on new pages as part of a publishing checklist
- **Competitor research**: extract the heading outline from competitor pages to understand their content structure

### Input

| Parameter | Type | Default | Description |
|-----------|------|---------|-------------|
| `url` | string | - | Single URL to analyze |
| `urls` | array | - | List of URLs to analyze, one per line |
| `maxUrls` | integer | 100 | Maximum number of URLs to process per run |
| `timeoutSecs` | integer | 300 | Overall actor timeout in seconds (max 3600) |
| `requestTimeoutSecs` | integer | 30 | Per-request timeout in seconds (max 120) |
| `proxyConfiguration` | object | Datacenter (Anywhere) | Proxy type and location for requests. Supports Datacenter, Residential, Special, and custom proxies. Optional. |

#### Example input

```json
{
    "urls": [
        "https://apify.com",
        "https://apify.com/about"
    ],
    "maxUrls": 50,
    "requestTimeoutSecs": 30,
    "proxyConfiguration": { "useApifyProxy": true }
}
````

### What data does this actor extract?

The actor stores one result per URL in a dataset. Each entry contains:

```json
{
    "url": "https://apify.com",
    "inputUrl": "https://apify.com",
    "pageTitle": "Apify: Full-Stack Web Scraping and Data Extraction Platform",
    "h1Count": 1,
    "h2Count": 6,
    "h3Count": 12,
    "h4Count": 0,
    "h5Count": 0,
    "h6Count": 0,
    "headingTotalCount": 19,
    "headingDepth": 3,
    "hasMissingH1": false,
    "hasMultipleH1": false,
    "skippedLevels": [],
    "hierarchyIssues": [],
    "h1Texts": ["Build reliable web scrapers. Fast."],
    "headings": [
        { "level": 1, "text": "Build reliable web scrapers. Fast.", "order": 1 },
        { "level": 2, "text": "Why Apify?", "order": 2 }
    ],
    "statusCode": 200,
    "errorMessage": "",
    "scrapedAt": "2025-09-15T14:23:11.042Z"
}
```

| Field | Type | Description |
|-------|------|-------------|
| `url` | string | Final URL after any redirects |
| `inputUrl` | string | Original URL provided as input |
| `pageTitle` | string | HTML page title |
| `h1Count` | integer | Number of H1 tags |
| `h2Count` | integer | Number of H2 tags |
| `h3Count` | integer | Number of H3 tags |
| `h4Count` | integer | Number of H4 tags |
| `h5Count` | integer | Number of H5 tags |
| `h6Count` | integer | Number of H6 tags |
| `headingTotalCount` | integer | Total headings across all levels |
| `headingDepth` | integer | Deepest heading level used (1-6) |
| `hasMissingH1` | boolean | True if no H1 tag exists |
| `hasMultipleH1` | boolean | True if more than one H1 exists |
| `skippedLevels` | array | Heading levels skipped in the hierarchy |
| `hierarchyIssues` | array | Plain-language descriptions of each issue found |
| `h1Texts` | array | Text content of each H1 tag |
| `headings` | array | All headings in document order with level, text, and position |
| `statusCode` | integer | HTTP status code for the page request |
| `errorMessage` | string | Error message if the page could not be fetched |
| `scrapedAt` | string | ISO 8601 timestamp of when the page was analyzed |

### How it works

1. Reads the `url` and `urls` inputs, deduplicates them, and caps the list at `maxUrls`
2. For each URL, sends an HTTP GET request with a realistic browser User-Agent
3. Parses the response HTML with BeautifulSoup and finds all H1-H6 tags in document order
4. Counts headings by level, records each heading's text and position
5. Walks the heading sequence to detect missing H1s, multiple H1s, and skipped levels
6. Pushes one result record per URL to the Apify dataset

### Integrations

Connect Heading Structure Analyzer with other apps using [Apify integrations](https://apify.com/integrations). You can pipe results into Google Sheets, Zapier, Make, Slack, Airbyte, GitHub, or any tool that reads from the Apify API. You can also set up [webhooks](https://docs.apify.com/integrations/webhooks) to trigger downstream actions when a run completes.

### FAQ

**Does this actor work on JavaScript-rendered pages?**
It works on standard server-rendered HTML. If the page requires JavaScript to render headings (single-page apps, React/Vue frontends), the headings may not appear in the raw HTML. For JS-heavy pages, consider a browser-based scraping approach.

**What counts as a heading hierarchy issue?**
Three things: no H1 on the page, more than one H1, and skipped heading levels (e.g. the first heading after an H2 is an H4, skipping H3). All three are listed in the `hierarchyIssues` field with plain-language descriptions.

**How many URLs can it process per run?**
Up to 1,000 URLs. Set `maxUrls` to cap the count if you want shorter runs during testing.

**Do I need a proxy?**
Most public websites work fine without one. Enable datacenter proxies if you are hitting pages that rate-limit or block scrapers. Switch to residential proxies for sites that block datacenter IPs.

**Why is `errorMessage` set but `hierarchyIssues` is empty?**
`errorMessage` fires when the page could not be fetched at all (network error, HTTP 4xx/5xx). `hierarchyIssues` only applies when the page loaded successfully but its heading structure has problems. They are independent.

### Run heading structure analysis at scale

Manual heading audits break down past a few dozen pages. Heading Structure Analyzer runs the same check across hundreds of URLs in minutes and returns structured data you can sort, filter, and export. Pair it with a sitemap scraper to cover an entire site in one workflow.

# Actor input Schema

## `url` (type: `string`):

Single URL to analyze for heading structure. Must start with http:// or https://.

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

List of URLs to analyze. Enter one URL per line. Use this for bulk analysis of multiple pages.

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

Maximum number of URLs to process per run. Caps cost on large batches.

## `timeoutSecs` (type: `integer`):

Overall actor timeout in seconds. The run stops after this time regardless of progress.

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

Per-request timeout in seconds. Requests that exceed this limit are skipped and logged as errors.

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

Select proxies to use for requests. Helps avoid IP blocking and rate limits. Datacenter proxies are fastest; Residential proxies are harder to detect.

## Actor input object example

```json
{
  "url": "https://apify.com",
  "urls": [
    "https://apify.com",
    "https://apify.com/about"
  ],
  "maxUrls": 100,
  "timeoutSecs": 300,
  "requestTimeoutSecs": 30,
  "proxyConfiguration": {
    "useApifyProxy": true
  }
}
```

# 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 = {
    "url": "https://apify.com",
    "proxyConfiguration": {
        "useApifyProxy": true
    }
};

// Run the Actor and wait for it to finish
const run = await client.actor("zerobreak/heading-structure-analyzer").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 = {
    "url": "https://apify.com",
    "proxyConfiguration": { "useApifyProxy": True },
}

# Run the Actor and wait for it to finish
run = client.actor("zerobreak/heading-structure-analyzer").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 '{
  "url": "https://apify.com",
  "proxyConfiguration": {
    "useApifyProxy": true
  }
}' |
apify call zerobreak/heading-structure-analyzer --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "command": "npx",
            "args": [
                "mcp-remote",
                "https://mcp.apify.com/?tools=zerobreak/heading-structure-analyzer",
                "--header",
                "Authorization: Bearer <YOUR_API_TOKEN>"
            ]
        }
    }
}

```

## OpenAPI specification

```json
{
    "openapi": "3.0.1",
    "info": {
        "title": "Heading Structure Analyzer",
        "description": "Heading structure analyzer that pulls H1-H6 tags from any URL, flags missing headings, duplicate H1s, and skipped levels, so SEO teams can fix hierarchy problems before rankings drop.",
        "version": "0.0",
        "x-build-id": "w2hvXk9roIjG1Ey3q"
    },
    "servers": [
        {
            "url": "https://api.apify.com/v2"
        }
    ],
    "paths": {
        "/acts/zerobreak~heading-structure-analyzer/run-sync-get-dataset-items": {
            "post": {
                "operationId": "run-sync-get-dataset-items-zerobreak-heading-structure-analyzer",
                "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/zerobreak~heading-structure-analyzer/runs": {
            "post": {
                "operationId": "runs-sync-zerobreak-heading-structure-analyzer",
                "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/zerobreak~heading-structure-analyzer/run-sync": {
            "post": {
                "operationId": "run-sync-zerobreak-heading-structure-analyzer",
                "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",
                "properties": {
                    "url": {
                        "title": "URL",
                        "type": "string",
                        "description": "Single URL to analyze for heading structure. Must start with http:// or https://."
                    },
                    "urls": {
                        "title": "URLs",
                        "type": "array",
                        "description": "List of URLs to analyze. Enter one URL per line. Use this for bulk analysis of multiple pages.",
                        "items": {
                            "type": "string"
                        }
                    },
                    "maxUrls": {
                        "title": "Max URLs",
                        "minimum": 1,
                        "maximum": 1000,
                        "type": "integer",
                        "description": "Maximum number of URLs to process per run. Caps cost on large batches.",
                        "default": 100
                    },
                    "timeoutSecs": {
                        "title": "Timeout (seconds)",
                        "minimum": 10,
                        "maximum": 3600,
                        "type": "integer",
                        "description": "Overall actor timeout in seconds. The run stops after this time regardless of progress.",
                        "default": 300
                    },
                    "requestTimeoutSecs": {
                        "title": "Request timeout (seconds)",
                        "minimum": 5,
                        "maximum": 120,
                        "type": "integer",
                        "description": "Per-request timeout in seconds. Requests that exceed this limit are skipped and logged as errors.",
                        "default": 30
                    },
                    "proxyConfiguration": {
                        "title": "Proxy configuration",
                        "type": "object",
                        "description": "Select proxies to use for requests. Helps avoid IP blocking and rate limits. Datacenter proxies are fastest; Residential proxies are harder to detect."
                    }
                }
            },
            "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
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
```
