skillfed

mdformat-toc

Mdformat plugin to generate table of contents

mdformat-toc v0.5.0 105.9K downloads/30d#12,675 on PyPI27
Permissive license MIT AGING released

What it is and what it does

Mdformat-toc extends mdformat, a Markdown formatter, with the ability to automatically generate and update a table of contents. You mark a location in your Markdown file with an HTML comment (<!-- mdformat-toc start -->), then run mdformat, and the plugin generates a ToC listing the headings in your document at that location.

By default, the plugin creates HTML anchors for each heading so ToC links work across different Markdown renderers. You can configure which heading levels to include, disable anchor generation, and choose between GitHub and GitLab slug functions for link generation. The plugin is designed to work with mdformat's standard formatting workflow and requires only mdformat as a runtime dependency.

Use it for:

  • Auto-generate and keep a table of contents synchronized in long Markdown documentation files.
  • Maintain consistent heading-to-anchor mappings across GitHub and GitLab hosted Markdown.
  • Integrate ToC generation into CI/CD pipelines that already use mdformat for Markdown formatting.
  • Generate navigable ToCs in README files without manually updating links when headings change.
  • Configure heading-level filtering to create ToCs that exclude top-level or deeply nested headings.

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

Mdformat-toc is an mdformat plugin that automatically generates and maintains a table of contents in Markdown files, with configurable heading levels and anchor generation.

Yes, if you use mdformat and need automated table-of-contents generation in Markdown files. The package is straightforward to install, has no security vulnerabilities, and works with current Python versions. The 303-day gap since last release suggests maintenance rather than active development, but the repository is not archived and the plugin remains functional for its intended use.

Install

mdformat-toc on PyPI

pip

pip install mdformat-toc

uv

uv add mdformat-toc

poetry

poetry add mdformat-toc

Installing mdformat-toc

Before you install

Low friction install with a single runtime dependency on mdformat. The package is aging (303 days since last release) but the repository remains active and not archived, with support for current Python versions (3.9 through 3.14).

License in practice

MIT license permits commercial and private use with minimal restrictions; you may use, modify, and distribute the package freely provided you retain the license notice.

Quickstart

pip install mdformat-toc

# Add to your Markdown file:
# <!-- mdformat-toc start -->
# Then run:
mdformat your_file.md

Requires mdformat to be installed; mdformat-toc works as a plugin that extends mdformat's formatting capabilities.

Verify before relying

  • Whether the package is actively maintained or in maintenance-only mode given the 303-day gap since last release.
  • Real-world compatibility with Markdown renderers other than GitHub and GitLab.

Package facts

License MIT (permissive)
Python support supports the current Python release (>=3.9)
Install friction low — pure-Python wheel
Runtime dependencies 1 — mdformat
Maintenance aging — 303 days since the last release
Last repo commit
First released
Downloads 105,855/month — #12,675 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: mdformat_toc-0.5.0-py3-none-any.whl

Keywords: mdformat, markdown, commonmark, formatter

License :: OSI Approved :: MIT LicenseProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Programming Language :: Python :: 3.9Topic :: DocumentationTopic :: Text Processing :: MarkupTyping :: Typed

Tags

markdown table of contents generatormdformat plugin tocauto-generate markdown tocmarkdown heading indexmdformat documentation helpermarkdown anchor generationtoc markdown formatter
markdown-toolingdocumentation-automation

More Markup packages