📑

Markdown Table of Contents

Build a table of contents from Markdown headings, with anchor links, indentation or numbering
Table of contents 📂 Text 👤 ToolWorld 🏷️ v1.2.2
Loading...
Input Paste or type text; it is processed locally
Markdown
Settings Choose how to process
Output style

Everything runs in the browser; your text is never uploaded

Enter text and press process. Everything runs locally; nothing is uploaded

Result Copy the result in one click

How to Use

📖 Tool Introduction


Pull the headings out of a Markdown document and build a table of contents, in three forms: with anchor links, as plain indented lines, or with hierarchical numbering.

A long document almost always needs a contents list, and maintaining one by hand is unrewarding work. Rename a heading and the list is stale. Insert a section and every number after it shifts. Miss one of those edits and a reader clicks an entry and lands in the wrong place, which is worse than having no list at all. Generating it from the document cannot drift, because the document is the source: change it, generate again, and the two agree by construction.

One trap is worth calling out because it ruins the output when missed. A fenced code block very often contains lines starting with a hash, since that is how comments are written in most scripting languages. Unless the fence state is tracked, every one of those comment lines is read as a heading and the contents fills up with entries that are not sections. The parser here watches for the fence markers and skips everything between them.

Anchors follow the convention used by the common renderers: lower case, punctuation removed, spaces turned into hyphens. That is why the generated links work when pasted back in rather than merely looking like they should. Chinese titles keep their characters, because the renderers keep them too, and stripping them would produce anchors that point at nothing.

The numbered form keeps a counter per level and resets the deeper ones whenever a parent advances, which gives the one, one point one, one point two, two sequence that a formal document wants. The result reports how many headings were found and how deep the structure goes, and everything runs in the browser so nothing is uploaded.

Placement is worth a thought once the contents exists. Putting it at the top is the convention for a document meant to be navigated, while the bottom suits a document meant to be read straight through, where a list at the front is an obstacle. Some platforms inject one automatically from the headings, in which case generating it here is for copying into a document those platforms do not handle, rather than for pasting into every file.

✨ Key Features


  • Extracts headings at all six levels
  • Three forms: anchor links, plain indentation, hierarchical numbering
  • Hash comments inside code blocks are skipped
  • Anchors follow the common renderers, so the links actually jump
  • Numbering maintained per level, with children reset when a parent advances
  • Runs locally: nothing is uploaded

🚀 How to Use


  1. Paste the Markdown document on the left
  2. Pick a contents style on the right
  3. Press process, or use Ctrl plus Enter
  4. The result box shows the contents with the heading count and deepest level
  5. Copy result puts it on your clipboard, ready to paste at the top of the document

⚠️ Things to Note


  • Data source: Based on Markdown heading syntax and the anchor rules of the common renderers; conversion runs in the browser
  • Hashes in code are not headings: Comment lines inside fenced blocks are skipped and never reach the contents
  • Anchor rules vary slightly: A few platforms differ, so if a link does not jump, switch to the plain form
  • Repeated titles: When a title repeats, the anchor gains a hyphen to keep the two apart
  • Privacy: Everything runs in the browser. What you paste is never sent to a server

Related

⏫︎