TOOLGRID
首页图片工具PDF 工具视频工具音频工具
更多
开发工具Web 与 SEO分类文本工具计算器关于
菜单
首页图片工具PDF 工具视频工具音频工具开发工具Web 与 SEO分类文本工具计算器关于
TOOLGRID

需要某项具体功能时,完整工具箱始终可用。

© 2026 TOOLGRID。保留所有权利。

工具

图片工具PDF 工具视频工具音频工具

资源

分类隐私政策

站点

关于条款联系
  1. 首页
  2. Text Tools
  3. Markdown TOC Generator

Markdown TOC Generator

Generate a Markdown table of contents — GitHub / GitLab / plain slugs, configurable depth, auto-dedup.

Pasted text or typed values→Markdown TOC Generator result浏览器本地处理

Loading tool…

格式与处理方式

工具代码会在浏览器中处理所选文件和输入内容,不会将其提交给 TOOLGRID 的处理接口。

输入
Pasted text or typed values
输出
Markdown TOC Generator result
运行引擎
Browser APIs
浏览器内运行这个工具能做什么

In-browser Markdown TOC generator. Extracts headings, generates nested anchor-linked TOC, supports GitHub-compatible slug style.

GitHub-style anchors follow GitHub's documented basic rules for plain heading text: lowercase letters, spaces changed to hyphens, punctuation removed, Unicode preserved, and duplicate anchors suffixed. ASCII-only anchors deliberately remove non-ASCII characters and collapse repeated separators for older or restricted destinations.

Other settings: cap depth at H2/H3/H4/H5/H6 (deeper headings are skipped), and optionally exclude the document's H1 title (most READMEs use H1 as the document title and don't want it in the TOC).

代表性任务

这个工具可以完成什么

Add a TOC to a long README

READMEs over a few screens benefit from a top-of-file TOC. Paste your full README in, copy the output, and paste it after the intro. Use GitHub-style anchors for plain headings rendered on GitHub.

Generate navigation for a docs site

Many static-site generators (Docusaurus, Nextra, MkDocs) consume Markdown with anchor links. Use this tool to pre-generate the TOC instead of relying on the framework's auto-TOC plugin if you want manual control.

Build a multi-section design doc index

Long internal design docs benefit from a navigable TOC. The depth cap means you can show top-level sections only (H2) or include sub-sections for fine-grained navigation.

使用边界

依赖结果前需要检查什么

  • Performance and maximum practical input size depend on browser memory, device speed, and the structure of the input.
  • Review the generated result before replacing or publishing an original file.
MDN Web APIs

如何使用

  1. 1

    Pick max heading depth (default H3), anchor style (default GitHub-style), and whether to skip H1.

  2. 2

    Paste your Markdown document into the input area.

  3. 3

    Copy the generated TOC and paste it at the top of your document (typically right after the title and intro).

使用场景
Add a TOC to a long README

READMEs over a few screens benefit from a top-of-file TOC. Paste your full README in, copy the output, and paste it after the intro. Use GitHub-style anchors for plain headings rendered on GitHub.

Generate navigation for a docs site

Many static-site generators (Docusaurus, Nextra, MkDocs) consume Markdown with anchor links. Use this tool to pre-generate the TOC instead of relying on the framework's auto-TOC plugin if you want manual control.

Build a multi-section design doc index

Long internal design docs benefit from a navigable TOC. The depth cap means you can show top-level sections only (H2) or include sub-sections for fine-grained navigation.

Prepare an ASCII-compatible fallback

If a destination cannot use Unicode fragments, switch to ASCII-only anchors and review any heading that loses distinguishing characters or falls back to <code>#section</code> before publishing.

Audit document structure

Generating the TOC is a fast way to see if your headings flow logically. A TOC with too-deep nesting, repeated section names, or missing H2-level sections usually signals an organization problem worth fixing.

使用技巧
Duplicate headings auto-deduplicate the slug

If two headings resolve to the same anchor, the later one gets an incrementing suffix such as <code>-1</code>. Anchors are assigned before depth and H1 filters, so omitted headings still reserve their destination fragment.

Code blocks are ignored

Lines that look like headings inside <code>```</code>-fenced code blocks (e.g., a shell prompt that includes a hash) are correctly excluded from the TOC.

Indent reflects relative depth, not absolute

If your document starts at H2 (no H1, or H1 skipped), H2 sits flush-left in the output. The TOC tree's root is whichever level is shallowest in your filtered headings.

ASCII-only strips non-ASCII characters

GitHub-style anchors keep Unicode letters, so a Chinese or Korean heading can retain its script. ASCII-only removes those characters for restricted destinations; review any empty or ambiguous result.

常见问题

Does the tool run entirely in my browser?

Parsing and slug generation use browser-side JavaScript. Tool code processes selected files and entered content in your browser and does not submit them to a TOOLGRID processing endpoint. Browser-local processing avoids a TOOLGRID upload path, but it is not a blanket security guarantee.

What anchor styles are supported?

Two: GitHub-style (default — lowercase, Unicode-preserving, spaces to hyphens, most punctuation removed) and ASCII-only (non-ASCII characters removed and repeated separators collapsed). Check complex inline formatting against the final renderer before publishing.

Why is my generated TOC link broken on GitHub?

Hover the rendered heading and compare GitHub's copied fragment with the generated link. Complex inline Markdown can be normalized by the renderer before slugging, and renderer-specific rules can differ from this tool's documented plain-heading behavior. Duplicate suffixes also count headings omitted from the TOC.

Does it support setext headings (<code>===</code> / <code>---</code>)?

Not currently — only ATX-style <code>#</code>-prefixed headings are recognized. If your document uses setext (underline) syntax, convert to ATX first or paste-and-pre-process.

How does the tool handle headings with inline Markdown (links, code, emphasis)?

The TOC label preserves the heading source, while anchor normalization removes punctuation. The tool does not run a full inline-Markdown renderer before slugging, so headings with links, code spans, HTML, or nested formatting must be checked against the destination's rendered anchor.

Can I generate TOCs for HTML, AsciiDoc, or reStructuredText?

This tool targets Markdown only. For other formats, look for format-specific TOC generators (Pandoc has TOC generation for many input formats; AsciiDoc has built-in <code>:toc:</code> directive).

Why is the H1 skipped by default?

Most documents use H1 as the document title ("README", "My Project"). Including the title in its own TOC creates a noisy first entry that points back to the top of the page. Toggle it off if your structure uses H1 for sections instead of one document title.

继续当前流程

下一步常用工具

如果还需要校验、转换或复用结果,可以继续打开相近的浏览器本地工具。

Markdown Live Preview文本工具 · 本地→Slug Generator文本工具 · 本地→字数统计文本工具 · 本地→