Markdown Table of Contents Generator
Paste any Markdown document and get a linked table of contents ready to paste at the top.
100% client-side · no upload
How to generate a table of contents
- Paste your Markdown document into the left panel.
- The TOC appears automatically in the right panel.
- Click Copy TOC to copy it to your clipboard.
- Paste the TOC at the top of your document, after the title heading.
- Verify the links work by opening your document in a Markdown renderer.
Common use cases
- Long README files: Add navigation to multi-section GitHub READMEs.
- Documentation pages: Let readers jump to the section they need.
- Technical guides: Structure long tutorials or how-to guides.
- Release notes: Link to each version section in a CHANGELOG.
Related tools: Markdown Preview · Headings Extractor · Markdown to HTML
常見問題
- How does the TOC generator work?
- The tool scans every line of your Markdown for heading markers (# through ######), extracts the heading text, generates an anchor slug, and builds a nested list of Markdown links pointing to those anchors.
- How are anchor slugs generated?
- Anchors are generated the same way GitHub does it: the heading text is lowercased, spaces are replaced with hyphens, and non-alphanumeric characters are removed. For example, "## My Heading!" becomes #my-heading.
- Will the anchor links work on GitHub?
- Yes. GitHub generates heading anchors using the same algorithm, so the TOC links will work correctly in GitHub README files.
- Can I control the nesting depth?
- The tool generates entries for all heading levels present in the document (h1–h6). Indentation reflects the nesting: h2 is indented 2 spaces, h3 is 4 spaces, and so on.
- Where should I place the TOC in my document?
- Convention is to place the TOC after the document title (h1) and before the first section heading (h2). Some tools use a <!-- TOC --> comment as a placeholder.
- Does it support duplicate headings?
- The generator does not currently deduplicate anchors. If your document has two headings with identical text, both TOC entries will point to the same anchor. Most renderers (including GitHub) suffix duplicate anchors with -1, -2, etc. — this may require manual adjustment.
- Does this work offline?
- Yes. The generator runs in your browser and works without a network connection.
- Can I preview the full document with the TOC?
- Use the Markdown Preview tool to render your document with the TOC pasted in.