Open-Awesome
CategoriesAlternativesStacksSelf-HostedExplore
Open-Awesome

© 2026 Open-Awesome. Curated for the developer elite.

TermsPrivacyAboutGitHubRSS
  1. Home
  2. Command-Line Apps
  3. DocToc

DocToc

MITJavaScriptv2.4.1

Generates and updates table of contents for markdown files in local git repositories with GitHub-compatible anchors.

Visit WebsiteGitHubGitHub
4.4k stars489 forks0 contributors

What is DocToc?

DocToc is a command-line tool that automatically generates and maintains a table of contents for Markdown files within a local Git repository. It scans directories recursively to create TOCs, ensuring links are compatible with anchor formats used by platforms like GitHub, GitLab, and Bitbucket. This automates documentation maintenance and improves navigation for readers.

Target Audience

Technical writers, open-source maintainers, and developers who manage documentation in Markdown files within Git repositories and want to automate TOC creation and updates.

Value Proposition

Developers choose DocToc for its lightweight, non-intrusive automation with fine-grained control over TOC placement, formatting, and platform-specific link compatibility. It stands out by offering incremental updates without duplicates, CI/CD integration with dry-run mode, and flexible configuration options like custom headers, footers, and heading level ranges.

Overview

📜 Generates table of contents for markdown files inside local git repository. Links are compatible with anchors generated by github or other sites.

Use Cases

Best For

  • Automatically generating and updating table of contents for all Markdown files in a Git repository with a single command.
  • Ensuring TOC links are compatible with specific platforms like GitHub, GitLab, Bitbucket, Node.js, or Ghost via command-line flags.
  • Integrating TOC maintenance into CI/CD pipelines using dry-run mode to check if documentation is up-to-date during builds.
  • Using as a pre-commit Git hook to automatically update TOCs before commits, keeping documentation synchronized.
  • Placing TOCs at custom locations within Markdown files using pragma comments, not just at the top.
  • Selectively updating only files with existing TOCs or ignoring specific files to streamline documentation workflows.

Not Ideal For

  • Projects using non-Markdown documentation formats like HTML or reStructuredText
  • Teams that prefer graphical user interfaces over command-line tools for documentation editing
  • Environments where installing Node.js is prohibited or impractical

Pros & Cons

Pros

Automatic TOC Generation

Scans directories recursively to create and update table of contents for all Markdown files with a single command, as demonstrated in the 'Adding toc to all files in a directory' section.

Multi-Platform Compatibility

Supports link formats for GitHub, GitLab, Bitbucket, Node.js, and Ghost via command-line flags, ensuring TOCs work seamlessly across different platforms.

Incremental Updates

Intelligently updates existing TOCs without creating duplicates when re-run, as highlighted in the 'Update existing doctoc TOCs effortlessly' section.

CI/CD Integration

Offers dry-run mode for checking if docs are up-to-date in build pipelines and pre-commit Git hook support, facilitating automated documentation maintenance.

Cons

Limited Heading Level Support

The --minlevel option only supports values 1 and 2, restricting flexibility for documents with complex heading hierarchies, as noted in the configuration section.

Node.js Dependency

Requires Node.js and npm for installation, which adds overhead in environments without JavaScript tooling or where minimal dependencies are preferred.

Command-Line Only

Lacks a graphical interface, making it less accessible for non-technical users or those who prefer visual tools for documentation workflows.

Frequently Asked Questions

Quick Stats

Stars4,438
Forks489
Contributors0
Open Issues25
Last commit2 days ago
CreatedSince 2012

Tags

#documentation-tool#cli-tool#ci-cd#nodejs#markdown#docker

Built With

N
Node.js
D
Docker

Links & Resources

Website

Included in

Command-Line Apps19.2k
Auto-fetched 1 day ago

Related Projects

glowglow

Render markdown on the CLI, with pizzazz! 💅🏻

Stars24,541
Forks651
Last commit2 days ago
gripgrip

Preview GitHub README.md files locally before committing them.

Stars6,785
Forks438
Last commit1 year ago
mdvmdv

Styled Terminal Markdown Viewer

Stars1,877
Forks108
Last commit1 year ago
Community-curated · Updated weekly · 100% open source

Found a gem we're missing?

Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.

Submit a projectStar on GitHub