Skip to content


Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time


MIT license GitHub release Go Report Card Build Status Coverage Status

Insert and maintain a table of contents in Markdown files.


tocenize generates a TOC (table of content) from Markdown files and inserts or updates it in the given file.

  • Cross-platform command line utility
    • Windows, Linux, Mac and *bsd (anything the Go compiler will handle)
  • Anchor links are compatible to GFM (Github flavoured Markdown)
  • Automatic "intelligent" insertion of new TOC
  • Update existing TOCs without moving it
  • Configurable max. and min. header depth
  • Line endings are kept intact (LF or CRLF is detected and then used for new lines)


Pre-compiled binaries

Compiled binaries are available on the releases page.

Make sure to place it somewhere in your $PATH.

From source

If you have a working Go environment, simply run:

go install

If you've added $GOPATH/bin to your $PATH, you can now run tocenize from anywhere.


The output of tocenize -h should be self explanatory:

tocenize [options] FILE...

  -d    print full diff to stdout
  -e    update only existing TOC (no insert)
  -indent string
        string used for nesting (default "\t")
  -max int
        maximum depth (default 99)
  -min int
        minimum depth (default 1)
  -p    print full result to stdout
  -v    print version



All notable changes to this project will be documented in the changelog.

The format is based on Keep a Changelog and this project adheres to Semantic Versioning.


This project is released under the MIT license.