Skip to content
Markdown to PDF
More free tools

One click builds the contents

Markdown to PDF with a table of contents

Writing a table of contents by hand is slow, and it goes out of date the moment you rename a heading. This page builds it for you. Press one button and a linked list of your headings appears at the cursor.

Page options
Page numbers
Front matter

Preview (what the PDF will look like)

The button opens your browser print dialog. Choose Save as PDF as the destination. For a clean page, turn off "Headers and footers". The file is named after your first heading. Everything stays on your device.

Saving a PDF on a phone or tablet

iPhone and iPad (Safari)

  1. Press Download PDF.
  2. On the page preview, spread two fingers apart. The PDF opens full screen.
  3. Tap the Share button, then Save to Files.

Android (Chrome)

  1. Press Download PDF.
  2. At the top of the print screen, set Destination to Save as PDF.
  3. Tap the round PDF button and choose where to save.

Two settings for a clean PDF

Your browser opens its print window next. In that window:

Picture of the print window (not clickable)
Destination Save as PDF Options Headers and footers (off) Background graphics (optional)
  1. Set Destination to Save as PDF.
  2. Turn off Headers and footers.

How to add the contents

  1. Paste your Markdown, or open the file.
  2. Click in the editor where the contents should go, usually under the title.
  3. Press Insert contents. A "Contents" heading and a linked list appear.
  4. Press Download PDF. Each entry is a link that jumps to its heading in the PDF.

What goes into the list

  • Headings at level 2 and level 3. Level 4 and below are left out so the list stays short.
  • The first level 1 heading is treated as the title and is skipped when it is the only one.
  • Headings inside code blocks are ignored, so a shell comment that starts with # is not listed.
  • An existing "Contents" heading is not listed in itself.
  • Two headings with the same name get separate links.

Keeping the list current

The list is plain Markdown after you insert it. It does not update on its own. If you add or rename a heading, delete the old list and press the button again.

You can also edit the list by hand. Remove entries you do not want, or change the labels. The links only need to keep the same name as the heading, in lowercase with hyphens.

Page numbers

A contents list is more useful with page numbers on the pages. Turn on Page numbers before you download. They print in the footer as "1 / 3" in Chrome and Edge. The list itself does not show the page of each entry, because a browser cannot know that in advance.

Questions

Do the contents entries show page numbers?

No. Each entry is a link to its heading. The pages carry their own numbers in the footer if you turn that on. A browser cannot know which page a heading lands on before it prints.

Can I limit the list to level 2 headings?

Insert the list, then delete the lines that start with two spaces. Those are the level 3 entries.

Will the links work in the PDF?

Yes. In a PDF viewer, clicking an entry jumps to its heading.

More ways to use this converter

More free tools from Bingemind