Table of contents generator
Paste a document and get its contents list, with anchors that work on GitHub. Choose how deep it goes, whether it is numbered, and whether it links at all.
Markdown
Table of contents
- [Install](#install) - [Usage](#usage) - [Options](#options) - [Examples](#examples) - [Contributing](#contributing)
How it works
- Headings are read from the document, skipping anything inside a fenced code block and any YAML front matter.
- Each entry gets GitHub's anchor: lowercase, punctuation dropped, spaces to dashes, and a numeric suffix when two headings would collide.
- Inline markdown in a heading is stripped for the label, so a heading containing a link or bold text reads as plain text in the list.
- Skip title leaves out a lone H1, because that is the document's title rather than a section.
Questions
Do these anchors work outside GitHub?
GitLab, Bitbucket and most static site generators use the same slug, so in practice yes. A few renderers prefix ids for safety, and then the links need that prefix too.
Why are two identical headings numbered?
Because they would otherwise produce the same anchor and every link would land on the first one. GitHub appends -1, -2 and so on, and so does this.
Can I put the contents list inside the document?
Yes, that is the usual place: right under the title. Copy it and paste it in, or use Open in viewer to see the result first.