Markdown Heading Extractor
Markdown Heading Extractor finds lines with zero to three leading spaces, one to six # characters, whitespace, and heading text. It outputs the level and raw trimmed text separated by a tab. Setext headings, headings inside fenced code blocks, inline cleanup, trailing closing hashes, and CommonMark container context are not interpreted.
Runs locally — files stay on your deviceWill # text inside a fenced code block be ignored?
No. The extractor scans matching lines without understanding fenced-code context.
ATX headings use one through six leading hash marks
In CommonMark, block context affects whether a line is a heading. This tool uses a multiline pattern and reports textual matches only.
How it works
Every matching line contributes the number of # characters, a tab, and the remaining trimmed text.
Key concepts
Extraction is not document parsing
Containers and code blocks can change the meaning of a matching line.
Output retains inline source
Emphasis, links, and trailing hashes remain text.
When to use it
- Scan a controlled ATX-only outline.
- Count heading levels.
- Feed simple heading text into another local workflow.
When not to use it
- Do not expect Setext headings.
- Do not analyze documents with matching lines inside code fences.
- Do not assume inline formatting or closing hashes are removed.
Worked examples
Two levels
- Input
# Title\n## Setup- Expected output
1\tTitle\n2\tSetup
Each ATX level is counted.
Setext style
- Input
Title\n=====- Expected output
No heading
Underline-style headings are unsupported.
Indented four spaces
- Input
# Code- Expected output
No heading
The pattern permits at most three leading spaces.
Common mistakes
Scanning code examples
False headings can appear inside fences. Correction: Use a CommonMark parser when context matters.
Expecting rendered text
Inline Markdown remains. Correction: Process inline nodes separately.
Expecting Setext support
Only # syntax matches. Correction: Convert headings to ATX or use a full parser.
Best practices
- Use ATX-only controlled documents.
- Review matches around code blocks.
- Validate outline levels separately.
Related operations and differences
Markdown Table of Contents Generator
Choose Markdown Table of Contents Generator when you need to build a nested linked outline from Markdown headings.; use Markdown Heading Extractor specifically for extract headings.
CSV to Markdown Table
Choose CSV to Markdown Table when you need to turn comma-separated rows into a Markdown table.; use Markdown Heading Extractor specifically for extract headings.
Document Link Extractor
Choose Document Link Extractor when you need to extract labeled links from Markdown or HTML.; use Markdown Heading Extractor specifically for extract headings.
HTML to Markdown Converter
Choose HTML to Markdown Converter when you need to convert common HTML elements into clean Markdown.; use Markdown Heading Extractor specifically for extract headings.
Markdown Table Generator
Choose Markdown Table Generator when you need to generate an empty Markdown table with custom columns.; use Markdown Heading Extractor specifically for extract headings.
Markdown Table to CSV
Choose Markdown Table to CSV when you need to convert a Markdown table into CSV rows.; use Markdown Heading Extractor specifically for extract headings.
Limitations and privacy
- Regex extraction only.
- No Setext, container, fenced-code, inline-AST, or duplicate-heading logic.
- Output is tab-separated text.
Document text is transformed locally in this browser.
Frequently asked questions
Are Setext headings supported?
No.
Are code fences understood?
No.
What levels are recognized?
One through six.
Is inline Markdown removed?
No.