Markdown TOC Generator - GitHub-Anchor Table of Contents
Pricing
from $0.64 / 1,000 generated tocs
Markdown TOC Generator - GitHub-Anchor Table of Contents
Paste-ready TOC for any markdown doc or URL: GitHub-compatible anchors, nested indentation, duplicate headings deduped, code fences ignored, setext + ATX parsed, links stripped from heading text. Up to 50 docs per run. $0.0008 per document, unfetchable URLs never charged.
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
4 days ago
Last modified
Categories
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" }]}
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