Free Markdown Table of Contents & Auto-Numbering Generator

Instantly generate nested, auto-numbered tables of contents for your Markdown documents. A free, browser-based tool to organize your headings and create outlines.

Built by@Akhenaten

AI Generation Prompt

Technical Specification: Markdown TOC & Auto-Numbering Generator

Overview

This single-file application is a browser-based utility designed to parse Markdown text, identify header structures, and generate an auto-numbered Table of Contents (TOC) with nested hierarchy. The application must be fast, responsive, and completely privacy-focused.

Core Architecture

  • Single File: The entire tool (HTML, CSS, JS) must be contained in one file.
  • No Persistence: Do not use localStorage, sessionStorage, or any form of cookies. If the page is refreshed, the input is cleared.
  • No Server Dependencies: All processing happens in-memory via Vanilla JS.
  • UI Framework: Tailwind CSS (via CDN) for styling to maintain a consistent SaaS-like aesthetic.

UI/UX Design

  • Layout:
    • Header: Simple, clean application title with a subtitle indicating the function.
    • Main Area: A split-pane view on desktops (Left: Input, Right: Output/Preview). On mobile, stack them vertically.
    • Configuration Toolbar: A floating or sticky header area for settings (numbering style, max-depth).
  • Color Palette:
    • Background: #F9FAFB (Off-white/Gray 50)
    • Panels: #FFFFFF (White) with a subtle drop shadow (shadow-md, rounded-lg).
    • Primary Action: #4F46E5 (Indigo 600) for primary buttons (Generate/Copy).
    • Text: #111827 (Gray 900) for headings, #374151 (Gray 700) for body text.
    • Borders: #E5E7EB (Gray 200).

Functional Requirements

  1. Input Handling: A textarea input where users paste their Markdown.
  2. Real-time Parsing: As the user types, the app parses the text using Regex to find ^#{1,6}\s+.
  3. Formatting Logic:
    • Generate hierarchical numbering: 1, 1.1, 1.1.1.
    • Create a list of internal links [Title](#link-anchor).
  4. Controls:
    • Buttons: "Copy to Clipboard", "Download as .md file", "Clear".
    • Toggles: "Include H1", "Include H2", etc.
  5. Feedback:
    • Smooth CSS transitions (transition-all) for button hover states.
    • Success states (e.g., "Copied!" tooltip) via custom, lightweight CSS-only popups (no alert()).

Developer Directives

  • Security: Do not use innerHTML to render user input to prevent XSS. Use textContent or text sanitization strategies.
  • Animations: Use standard CSS transition: all 0.2s ease for interactions.
  • Responsive: Ensure the textarea grows to fit at least 60% of the screen height on tablets/desktops.
  • Performance: Use requestAnimationFrame or debounced input listeners for the live preview generation to ensure the UI remains responsive during large text inputs.

Spread the word

3Total Views
gemini-3.0-flashAI Model

Files being used

index.html
9.8 KB
#markdown toc generator#markdown auto-numbering tool#markdown table of contents maker#nested markdown outline generator#free markdown heading formatter#markdown document structure tool

Frequently Asked Questions

Everything you need to know about using this application.

How does the Markdown auto-numbering algorithm work?

The tool parses your pasted Markdown content to identify headers from H1 through H6. It automatically establishes a hierarchical tree based on the level of each heading and assigns a sequential numerical identifier (e.g., 1, 1.1, 1.1.1) to each item found in the document structure. This system ensures that your document's outline is logically ordered regardless of the depth of your nesting. The numbering updates instantly as you adjust your heading levels or filter which headers to include in your generated table of contents.

Is my Markdown content stored or sent to a server?

This application operates strictly within your local web browser. No data, text, or Markdown content is transmitted to any external server, database, or API. Your privacy is guaranteed because the processing occurs entirely on your local machine using client-side JavaScript. Because of this architecture, you do not need to worry about the security of your proprietary or sensitive notes. Once you close your browser tab, all the content processed during your session is purged from memory, ensuring that no traces remain.

Can I customize the depth of the Table of Contents?

Yes, the utility features a configuration panel that allows you to specify the minimum and maximum heading levels to include in your output. By default, it captures H1 through H3, but you can expand this to include H4, H5, or H6 headers depending on the complexity of your document. Simply adjust the settings toggles in the configuration menu to filter out deeply nested sections that may clutter your outline. The preview area will refresh in real-time, allowing you to fine-tune the resulting list to exactly the level of detail you require for your document.

Does this tool work with standard Markdown syntax?

The generator is built to be compatible with standard Markdown (CommonMark) syntax, identifying lines that begin with one to six hash signs (#). It ignores headers that are improperly formatted or inline code blocks that happen to contain symbols resembling headers. Whether you are documenting code repositories, writing academic notes, or preparing a technical manual, the tool ensures high compatibility with common editors. If you encounter an issue, simply ensure your Markdown headers have the standard space following the hash sign, as this is the recognized convention for valid Markdown parsing.

Related Applications