Markdown Table of Contents Generator - GitHub Anchor TOC
Pricing
from $0.64 / 1,000 generated tocs
Markdown Table of Contents Generator - GitHub Anchor TOC
Builds a table of contents for Markdown, pasted or by URL, with GitHub-style anchor links and a depth setting. Returns a paste-ready TOC plus a heading outline with levels and slugs, up to 50 documents per run; failed URLs are free. For open-source maintainers, technical writers and docs teams.
Pricing
from $0.64 / 1,000 generated tocs
Rating
0.0
(0)
Developer
Broke to Built
Maintained by CommunityActor stats
0
Bookmarked
2
Total users
1
Monthly active users
14 days ago
Last modified
Categories
Features
Share
Markdown TOC Generator — GitHub-Anchor Table of Contents by API
Generate a correct, paste-ready table of contents for any markdown document — GitHub-compatible anchors, nested indentation, duplicate headings deduped — from raw markdown or a URL. Up to 50 documents per run, online, by API, or as an agent tool via Apify MCP.
Hand-maintaining a TOC drifts out of date the day someone renames a heading; naive generators break on the details (code fences containing #, setext === headings, links inside headings, two sections with the same name). This one handles all of those — and each behavior is asserted by our automated release test.
What you get
- toc — ready-to-paste markdown: nested
- [Heading](#anchor)lines, indented by level - outline — the same data structured:
{level, text, slug}per heading - headingCount, plus fetch metadata for URL inputs
- Correctness details: ATX (
#) and setext (===/---) headings both parsed; fenced code blocks skipped; inline links/emphasis stripped from heading text; GitHub slug rules (unicode kept, punctuation dropped); duplicate anchors dedupedsetup,setup-1, ... - minDepth/maxDepth — window the levels included (default 1-3)
- Fail-soft: an unfetchable URL never fails the run — it returns
{ok: false, error}and is never charged.
Input
{ "url": "https://raw.githubusercontent.com/apify/apify-sdk-js/master/README.md", "maxDepth": 3 }
Or raw text: { "markdown": "# Title\n## Section..." }. Bulk via urls array.
Output (real run, trimmed)
{"ok": true,"headingCount": 5,"toc": "- [Intro](#intro)\n- [Setext Title](#setext-title)\n - [Setup](#setup)\n - [Linked step](#linked-step)\n - [Setup](#setup-1)","outline": [{ "level": 1, "text": "Intro", "slug": "intro" },{ "level": 2, "text": "Setup", "slug": "setup" },{ "level": 2, "text": "Setup", "slug": "setup-1" }]}
Example
A real run on 2026-10-31 with the input this page's form is prefilled with:
{"markdown": "# Getting Started\n\n## Installation\n\n### Requirements\n\n## Usage\n\n## API Reference\n\n### Methods\n\n### Events","url": "https://raw.githubusercontent.com/apify/apify-sdk-js/master/README.md","urls": ["https://raw.githubusercontent.com/apify/apify-sdk-js/master/README.md"]}
It finished in 1 second and returned 2 results. It was charged for 2 file-processed events ($0.0016 on the Free plan). The first result (long text and lists cut for display):
{"maxDepth": 3,"minDepth": 1,"source": "inline","ok": true,"headingCount": 7,"toc": "- [Getting Started](#getting-started)\n - [Installation](#installation)\n - [Requirements](#requirements)\n - [Usage](#usage)\n - [API Reference](#api-referen…","outline": [{"level": 1,"text": "Getting Started","slug": "getting-started"},{"level": 2,"text": "Installation","slug": "installation"},{"level": 3,"text": "Requirements","slug": "requirements"},"… 4 more"]}
Pricing
$0.0008 per document parsed. No start fee. Unfetchable URLs are never charged.
No direct paid markdown-TOC incumbent was found on the store (2026-08-07 search across "markdown toc", "table of contents" — results are converters and crawlers). Pricing is cost-plus at ~5x measured run cost.
Honest limits
- Anchor slugs follow GitHub's rules; other renderers (GitLab, some SSGs) differ slightly on punctuation edge cases — the
outlinegives you text+level to re-slug for any target. - URL inputs are fetched as plain text — point at RAW markdown (e.g.
raw.githubusercontent.com), not an HTML-rendered page. - The TOC is generated, not inserted — splice it into your document wherever you keep it.
FAQ
Do code blocks containing # break it? No — fenced blocks (``` and ~~~) are tracked and their contents ignored. Asserted in our release test.
What about two sections with the same name?
Deduped exactly like GitHub: second ## Setup becomes #setup-1, so every TOC link lands on the right section.
Are setext headings (underlined with === or ---) supported? Yes, as h1/h2 respectively — plenty of older READMEs use them.
Can I generate TOCs for a whole docs repo?
Yes — pass up to 50 raw-file URLs via urls; each document gets its own record.
Why did some rows come back ok: false?
The URL 404'd or timed out. Recorded with the exact error, never charged.
Use from code or AI agents
curl -s "https://api.apify.com/v2/acts/EliAI~markdown-toc-generator/run-sync-get-dataset-items?token=$APIFY_TOKEN" \-X POST -H 'Content-Type: application/json' \-d '{"url": "https://raw.githubusercontent.com/your/repo/main/README.md"}'
Agents: connect Apify MCP and call the EliAI/markdown-toc-generator tool.
- Capability: generate GitHub-anchor TOC + structured outline from raw markdown or markdown URLs
- Required input:
markdown(string) orurl/urls - Returns: one record per document;
tocis paste-ready markdown,outlineis structured - Bounded: 50 documents per run, depth window 1-6; failures isolate per document
- Side effects: none
Who uses it
- Open-source maintainers generating a README table of contents with GitHub-compatible anchors
- Technical writers regenerating TOCs after renaming headings
- Docs teams processing a set of raw Markdown URLs in one run
- Developers adding a TOC step to a docs build pipeline
- Bloggers writing in Markdown who want a paste-ready contents list
Changelog
- 2026-11-01: Page text only: an Example section from a real run. Code, output and price are unchanged.