Generate a Markdown Table of Contents in IntelliJ
How IntelliJ IDEA builds a Markdown table of contents, what the generated block actually contains, and where its anchor links work or break after you share the file.
Generating a table of contents in IntelliJ IDEA is a convenient way to add navigation to a long Markdown file, such as a README, design note or runbook. It is not a visual effect. It writes ordinary Markdown text into your file. Whether that text is useful depends on where the file will be read. This review explains what the generated block contains and when it holds up after sharing. It also covers when a plain heading structure, with no table of contents, is the better choice.
Short verdict
An IDE-generated table of contents suits long Markdown documents that will be read in a renderer that creates heading anchors, such as a code-hosting platform or the IDE's own preview. You get quick navigation without typing link targets by hand. The tradeoff is that the links depend on anchor names that each renderer computes for itself, and the list goes stale whenever headings change. A table of contents adds little for short files, for documents pasted into channels that do not render Markdown, or for platforms that already show their own outline of the headings. In those cases, clear headings in plain text are enough.
How to generate it in IntelliJ
Recent IntelliJ-based IDEs bundle a Markdown plugin. In versions that include the feature, the table of contents command appears in the Generate menu while a Markdown file is open. The general workflow looks like this:
- 1. Open the .md file in the editor and place the caret where the table of contents should go, usually just below the title.
- 2. Open the Generate menu, either through Code > Generate or the Generate shortcut (commonly Alt+Insert on Windows and Linux, Cmd+N on macOS).
- 3. Choose the table of contents entry if your version offers it.
- 4. Check the inserted list in the preview pane and click a few entries to confirm they jump to the right sections.
- 5. After you rename, add or remove headings, regenerate or edit the list so it matches the document again.
Evidence gap: this article was not checked against a specific IDE build. The exact menu wording, the version that introduced the command and the default shortcuts are not confirmed here. The same goes for whether the IDE wraps the block in marker comments and refreshes it in place. If the entry is missing, check your IDE version and whether the bundled Markdown plugin is enabled before installing a third-party plugin.
What the transformation actually changes
The command reads your headings and inserts a nested Markdown list. Each item is a link whose text repeats a heading and whose target is a fragment, the part after a # sign, naming that heading's anchor. These are real characters stored in the file. The IDE is not applying a display-only layer or styling. Your headings themselves are not modified.
The anchors are a different matter. Markdown files do not store heading IDs. The renderer generates them at display time from the heading text. A widely used convention, popularized by GitHub-flavored rendering, works like this:
- 1. Lowercase the heading text.
- 2. Drop most punctuation.
- 3. Turn spaces into hyphens.
- 4. Add a numeric suffix to repeated headings so each anchor stays unique.
- Other renderers follow similar but not identical rules.
The following is an illustrative example of headings and a matching table of contents under that GitHub-style convention. It was written by hand to show the mechanism. It is not captured output from IntelliJ.
# Project Guide
- [Installation](#installation)
- [Configuration Options](#configuration-options)
- [Advanced: Proxy Settings](#advanced-proxy-settings)
- [FAQ](#faq)
## Installation
## Configuration Options
### Advanced: Proxy Settings
## FAQ
In this example, the colon in "Advanced: Proxy Settings" is removed, the text is lowercased and the spaces become hyphens, giving advanced-proxy-settings. The third-level heading appears as an indented sub-item. The top-level title is left out, which is a common choice, although tools differ on which heading levels they include.
In this context, terms like "reverse", "mirror" or "font" do not describe anything the command does. It does not reorder characters or flip glyphs. It does not substitute styled Unicode letters either. That last point matters for authors who decorate headings with Unicode "bold" or "script" letters to imitate a font. Those are distinct code points, not formatting. They can produce odd or unpredictable anchor slugs, they do not match ordinary search terms, and screen readers may announce them oddly or skip them. For a table of contents that links reliably, keep headings in ordinary text and use Markdown emphasis if you need visual weight.
Will it stay readable and usable after copying or sharing?
Because the result is plain Markdown, copying the raw file or its text keeps every character intact. Readability after sharing depends on the destination, not on the copy step.
- Markdown renderers that generate heading anchors: the list renders as clickable navigation, provided the renderer's slug rules match the targets that were written.
- Renderers with different slug rules: links can silently fail for headings that contain punctuation, non-English letters, emoji or duplicate names, even though the list still looks correct.
- Channels that show raw text: readers see brackets, parentheses and # fragments. The structure stays readable, but the links do nothing and add clutter.
- Rendered preview copied into a rich-text editor: the visible list usually comes across, but in-page links may point nowhere because the destination does not recreate the heading anchors.
- Platforms with a built-in outline: a hand-maintained table of contents duplicates navigation the reader already has.
Evidence gap: no specific hosting platform, wiki or chat tool was tested for this article. Before relying on the links, open the shared file in the actual destination and click entries that cover any tricky headings.
On accessibility, a table of contents written as a nested list with link text that matches each heading is a familiar pattern for assistive technology. It mirrors the heading structure that screen-reader users can already navigate. The main risks come from the heading text rather than the list:
- Decorative Unicode letters or emoji in headings, which may be read awkwardly or not at all.
- Link text that is vague or duplicated, which makes the list hard to scan by ear.
- No screen-reader testing was performed for this article.
Editing is the ongoing cost. Every heading rename can break a link or leave a stale entry, and nothing in plain Markdown warns you. Regenerating after structural edits, or checking the preview before committing, keeps the list honest. Search is generally unaffected, apart from repeating each heading's text once more in the file.
When to skip the table of contents
Plain headings without a generated list are preferable in four cases:
- The document is short enough to scan in one screen or two.
- It will mostly be pasted into email, chat or a ticket system that does not render Markdown.
- The reading platform already provides an outline.
- The headings change often and nobody will maintain the list.
In those situations, descriptive, ordinary-text headings deliver most of the navigation benefit with none of the link maintenance.