AST · headings · paragraphs · lists · code · blockquote · frontmatter

Parse Markdown into a JSON AST

Walk every block of a Markdown document and emit a typed node list — heading, paragraph, list, code, blockquote, hr, and YAML frontmatter — ready for content pipelines and CMSs.

Markdown → JSON
Input
252 B
24 lines
Output
721 B
45 lines
Status
ready
live
Ratio
2.86×
out/in
input · markdown
output · json ast
[
  {
    "type": "frontMatter",
    "value": "title: Hello\nauthor: jane"
  },
  {
    "type": "heading",
    "level": 1,
    "text": "Welcome"
  },
  {
    "type": "paragraph",
    "text": "A short paragraph with **bold** and a [link](https://example.com)."
  },
  {
    "type": "heading",
    "level": 2,
    "text": "Setup"
  },
  {
    "type": "list",
    "ordered": false,
    "items": [
      "install package",
      "run dev server",
      "open localhost"
    ]
  },
  {
    "type": "code",
    "lang": "js",
    "value": "console.log(\"hi\");"
  },
  {
    "type": "blockquote",
    "text": "Tip: read the docs first."
  },
  {
    "type": "hr"
  },
  {
    "type": "paragraph",
    "text": "End of doc."
  }
]
Quick Start

How to parse Markdown to JSON

A single-pass block walker tags each region by its type and emits a flat node list. Frontmatter is captured separately. Inline syntax stays as raw text inside the node.

  1. 01

    Paste Markdown

    Frontmatter is optional but is parsed when present.

    Parsing runs through marked with GFM extensions enabled — tables, task lists, strikethrough, and fenced code blocks all match GitHub’s rendering.

    inputGFMmarkedCommonMarklive
    input · markdownmd · GFM
    # Title
    loaded · GFMGFM · ready
  2. 02

    Walk blocks

    Headings, fences, lists, blockquotes, paragraphs.

    Soft-break behaviour is configurable: by default a single newline becomes a space (CommonMark), toggle on for chat-style <br> insertion.

    parsesoft-breaksoptionsconfiglive
    scan · optionsblocks · live
    heading…list…
    options applied · livelive
  3. 03

    Emit nodes

    Each block becomes a typed object with text/level/lang/items.

    The preview is scoped under a .mde class so its CSS doesn’t bleed into the rest of the page. Output HTML is whitespace-controlled for clean diffs.

    emitpreviewscoped CSSrenderstable
    out · renderedjson · ready
    [{"type":…}]
    rendered · liverendered
  4. 04

    Feed to a pipeline

    Pipe the AST into an SSG, CMS, or analytics job.

    Export covers both raw Markdown and rendered HTML; downloads stream as text/markdown or text/html via Blob + object URL.

    exportclipboard.md.htmlblob
    OK · exportedjson · done
    shipped
    shipped · ready to shipsuccess
Pro tips

Author Markdown that renders everywhere

GFM is the safe default

GitHub-Flavored Markdown is the de-facto baseline (tables, task lists, strikethrough). CommonMark is stricter but ubiquitous as a fallback.

Soft-break behaviour varies

A single newline is a space in CommonMark, a <br> in GFM. Toggle soft breaks when source matters.

Escape inside code fences

Backticks inside fenced blocks need a longer fence — three becomes four. Use ~~~ if your content has many backticks.

Anchors are slugified

GitHub lowercases, strips punctuation, and joins with hyphens. Duplicate headings get -1, -2 suffixes.

Tables need a header row

The dash row sets alignment (:---, :-:, ---:). Use Table Aligner for diff-friendly columns.

Front matter is YAML

Triple-dash blocks at the top of files are parsed by static-site generators. Use the Front-Matter Validator to catch syntax errors.

Use Cases

When to parse Markdown to JSON

Static sites, CMSs, ML datasets, content pipelines.

Static-site build

Pre-parse content for fast template rendering. Render path uses marked with GFM extensions enabled (tables, task lists, strikethrough, autolinks), so what you preview matches what GitHub publishes bit-for-bit. Soft-break behaviour is configurable for chat-style vs prose Markdown.

GFM-compliant

Headless CMS

Store posts as structured nodes instead of raw text. Pairs cleanly with the Markdown Cheatsheet for syntax you can't quite remember — callout blocks, footnotes, definition lists. Output stays diff-friendly so style-only changes don't drown out real edits in PRs.

GitHub-perfect

Indexing

Index headings and paragraphs in a vector store. Cross-platform safe: anchors, code fences, and tables behave identically on GitHub, GitLab, Bitbucket, and Gitea. Heading-anchor slugs follow GitHub's lowercase-and-hyphenate rules so deep links survive a docs migration.

diff-friendly

Analytics

Count code-block languages or heading depths. No server roundtrip — perfect for proprietary content you can't paste into a public tool. The full marked + GFM bundle ships with the page, so it works offline once loaded.

render-stable

ML datasets

Build training sets of structured Markdown. Front matter (YAML / TOML / JSON) passes through unchanged so static-site pipelines (Jekyll, Hugo, Astro, Eleventy) read it correctly. Pair with the Front-Matter Validator to catch syntax errors before deploy.

cross-platform

Cross-tool

Bridge Markdown to a JSON-only ingestion API. Output is reproducible: identical input always produces identical Markdown, so doc-generation scripts can rely on it for snapshot tests and embedded into release workflows.

SEO-friendly
FAQ

Frequently asked questions

Inspired by it — types match common AST conventions (heading, paragraph, list, code, blockquote, thematicBreak/hr) but the tree is flat, not nested, for simpler consumption.
Inline emphasis, links, and code stay as raw text inside each node's text field. Parse them downstream if needed.
It's captured verbatim into a frontMatter node. Run a YAML parser downstream — keeps this tool dependency-free.
Not yet — only the seven node types listed above. PRs welcome.
No. Parsing runs locally in your browser.
Suggest a tool

Something missing?

Tell us what you need. We ship the top requests every two weeks.

Sent straight to the maintainers · no account needed
47 in queue·8 shipped this month
Request queued. Thanks!