Markdown TOC Generator
Generate a Markdown table of contents — configurable, auto-injecting
Build a clean, GitHub-compatible TOC for any README, blog post, or docs page. Choose heading depth, bullet style, indent, and ordered vs unordered. Inject between<!-- TOC --> markers for repeatable updates.
If your README already has <!-- TOC --> and <!-- /TOC --> markers, the TOC is replaced between them; otherwise it is prepended to the top of the document.
How to use the Markdown TOC generator
- Paste Markdown into the source pane, or open a
.mdfile. - Pick a level range — H2 to H4 is the standard sweet spot for READMEs and docs pages.
- Choose a style: ordered (
1.) or unordered with your preferred bullet (-,*, or+). - Choose indent: 2-space (Prettier default) or 4-space.
- Copy the TOC — or copy the document with injected TOC if your source already has
<!-- TOC -->/<!-- /TOC -->markers.
Why a TOC matters
- Discoverability. GitHub renders the top of your README in search previews and on the repo home. A TOC tells visitors what's inside in 5 seconds.
- Long-doc navigation. Tutorials and API references quickly grow past one screen. A clickable TOC saves scrolling.
- Anchor reuse. Once you have anchors, you can link to specific sections from chat, social, or other docs.
- Static-site sidebars. Many docs frameworks (Docusaurus, MkDocs, Nextra) derive their right-sidebar nav from heading IDs identical to the ones used here.
Workflow: keep your README TOC fresh
# My library
<!-- TOC -->
<!-- /TOC -->
## Installation
…
Before each release:
- Paste your README here.
- Copy the "document with injected TOC".
- Commit. Done.
The injection is idempotent — re-running won't duplicate the TOC, and it preserves everything outside the markers.
Tips for high-quality TOCs
- Don't include H1. The TOC sits below your H1 title; including it duplicates the heading.
- Cap at H3 or H4 for READMEs. Deeper TOCs become noise. Save deeper levels for API references.
- Use ordered TOCs in long-form essays, unordered in technical docs.
- Pair with the Heading Auditor. A clean hierarchy produces a clean TOC.
Companion tools
- Markdown Slug Generator — see individual slugs.
- Markdown Slug Collision Simulator — verify slugs don't clash across files.
- Markdown Heading Audit — catch outline issues first.
Privacy & data
All processing happens inside your browser. We don't upload, log, or store the Markdown you paste.
Frequently asked questions
- Paste your Markdown, pick the minimum and maximum heading levels you want listed (typically H2–H4), choose list style (ordered or unordered), and copy the TOC. The generator builds GitHub-compatible anchor links from each heading.
- Yes. Add the markers `<!-- TOC -->` and `<!-- /TOC -->` to your README. When you copy the 'document with injected TOC', the generator replaces whatever is between those markers with the fresh TOC. Future runs are idempotent.
- GitHub-style: lowercase, strip non-word characters, collapse whitespace into hyphens, dedupe with `-1`, `-2` suffixes for duplicate headings within the same document. This matches what GitHub, Docusaurus, MkDocs, and most static-site generators do.
- Yes — switch the List style dropdown to Ordered. Each line becomes `1.` which renders correctly numbered on GitHub and most renderers (they auto-increment regardless of the literal digit used in source).
- Yes — see the [Markdown Slug Generator](/tools/markdown-slug-generator). The slug generator is best for one-off ID lookup; this page is best when you need a complete, configurable TOC with depth limits and injection support.
- No. Slug derivation, depth filtering, and injection all run inside your browser tab. We don't upload, log, or store any content.
How do I generate a Markdown table of contents?
Can it auto-update the TOC inside an existing README?
What slug algorithm does it use?
Can I get an ordered (numbered) TOC?
Is there a separate tool for raw slugs only?
Is my Markdown uploaded?
Related tools
More free browser tools in the same workflow.
Use the API
Automate this workflow in your app with the same engine that powers these browser tools.
New to the platform? Start with the API quickstart, then try a live request in the API playground.
Explore the API platform