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.
- [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.
The anchors do not match the HTML this site exports.
Correct, and it is deliberate on the export's side. Markdown to HTML prefixes every heading id with `md-`, because a bare id like `title` collides with a property of `document` and gets stripped by the sanitizer. This generator produces GitHub's plain anchors, because that is where a contents list is normally read. If you are pasting our exported HTML somewhere, add the same prefix to the links, or generate the list from the document once it is in its final home.
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.
The same tools, without a tab open
The checker in the app is this one, rule for rule, running on the files already on your device rather than on a copy you hand to a website. The converters overlap rather than match: the app writes markdown, HTML, Word and PDF, and this page goes wider on both sides. The generators stay here, because pasting a table into a page is a browser thing to be doing.
For iPhone, iPad and Mac.