Skip to content
POST
/api/v1/extract/frontmatter

Extract frontmatter API

Parse YAML frontmatter + body.

POST /api/v1/extract/frontmatter parses the YAML frontmatter from a markdown document into structured fields plus a body string. Compatible with Jekyll, Hugo, Astro, and Next.js MDX conventions.

Overview

Parses `---`-delimited YAML frontmatter at the top of a document. Supports strings, numbers, booleans, and simple inline arrays — matching the subset used by Jekyll, Hugo, Next.js MDX, Astro, and most static site generators.

Request

Authenticate with Authorization: Bearer YOUR_API_KEY and send a JSON body containing the parameters below. Pick your language:

curl -X POST 'https://trymarkdownviewer.com/api/v1/extract/frontmatter' \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"markdown":"---\ntitle: Hello\ntags: [a, b]\n---\nBody."}'

Body parameters

FieldTypeRequiredDescription
markdownstring
required
Markdown source.

Response

Success responses are wrapped in a data field. Errors use { error: { code, message } } with an appropriate HTTP status — see the error reference.

{
  "data": {
    "frontmatter": {
      "title": "Hello",
      "tags": [
        "a",
        "b"
      ]
    },
    "body": "Body.",
    "raw": "title: Hello\ntags: [a, b]",
    "hasFrontmatter": true
  }
}

Use cases

Static site ingest

Pull metadata to power index pages and search.

Migration

Move posts between SSGs that share frontmatter conventions.

Try in browser

Free tools that run the same logic locally — no API key, no upload.

Try it

Send a real request against your account in the API playground. Errors there link straight back to the error reference.