Markdown TOC Generator
Developer Tools · Added
A long README earns a table of contents, and hand-maintaining one guarantees a stale link within a month. Paste the document and this reads its headings, builds the nesting, and generates anchors that match how your host actually slugs them.
How to use the markdown toc generator
- 1Paste your Markdown document into the box.
- 2Pick the slug style for wherever it will be published — GitHub, GitLab or plain.
- 3Set which heading levels to include, and whether to keep the top-level title.
- 4Copy the result as Markdown, or as HTML if you need a rendered list.
Examples
A document with a repeated heading
- Input
- # Title, ## Setup, ### Install, ## Usage, ## Setup
- Result
- A nested list where the second Setup links to #setup-1, matching the numbered suffix GitHub appends — flagged with a note explaining the rename.
Skipping the title
- Input
- A README whose H1 is the project name
- Result
- A contents list starting at the H2 sections, since linking to the title from directly beneath it adds nothing.
About the markdown toc generator
Anchors are a property of the renderer
The single most common reason a generated table of contents does not work is that its anchors were built for a different renderer. Markdown itself has no concept of a heading anchor at all: the link target only exists because whatever converts the file to HTML invented an id for each heading, and every such tool made its own choices about case, punctuation and duplicates.
So the question is never 'what is the correct slug for this heading' but 'what will the thing rendering this file produce'. That is why the style setting sits at the top of this page rather than being decided for you.
How deep is worth listing
A table of contents that lists every heading down to the fourth level stops being navigation and becomes a second copy of the document. Two levels is usually right for a README, three for a specification with genuinely nested structure.
The other judgement is where to start. A README whose first heading is the project name gains nothing from a link back to it, and dropping that entry also removes a level of indentation from everything underneath — which is why skipping the H1 is the default here.
Frequently asked questions
Why do slug styles differ between hosts?
What happens when two headings have the same text?
Are headings inside code blocks picked up?
Does it understand the underlined heading style?
Related tools
Markdown to HTML Converter
Text Tools
Convert Markdown to clean HTML, or HTML back to Markdown, with a live preview.
Markdown Table Generator
Developer Tools
Build a Markdown table in a grid or from pasted CSV, with column alignment and pipes escaped for you.
Slug Generator
Text Tools
Turn a title into a clean URL slug, with accents transliterated and symbols spelled out.