String Utilities Tool bijgewerkt 2 dagen geleden

Markdown Front Matter Extractor

Split a Markdown file into its YAML front matter and its body. Paste the file and press Extract: the server parses the metadata into JSON and returns the raw YAML, the content without front matter, and a combined JSON result you can copy or download as markdown-front-matter.json.

Altijd gratis Eenvoudig in gebruik Directe resultaten Privé en veilig

Gebruik Markdown Front Matter Extractor

Markdown Front Matter-extractor

Haal YAML-frontmatter, geparseerde metadata en schone Markdown-inhoud uit documenten.

Markdown invoeren

Markdown-code plakken die mogelijk begint met YAML-frontmatter
De inleidende delen beginnen met --- op de eerste regel en eindigt met een andere ---.
Geen voorwerk
Detectiestatus
0 toetsen
Metadatavelden

Uitgefilterd resultaat

Metadata, onbewerkte YAML, inhoud en volledige JSON
Ruwe YAML kopiëren
Inhoud kopiëren
Tip voor het voorwoord
Gebruik deze tool voor blogberichten, documentatiepagina’s, inhoud van statische websites, wijzigingslogboeken en bestanden met YAML-metadata.
Link naar tool
Naar het klembord gekopieerd.
Help mee om deze tool te verbeteren

Inhoud lezen

Ontdek hoe de tool werkt en wanneer je deze kunt gebruiken.

Separate YAML metadata from the body of a Markdown file

Static site generators and content platforms such as Jekyll, Hugo, Eleventy, Astro, Docusaurus and many headless CMS tools store page settings at the top of each Markdown file in a block called front matter. It holds the title, date, author, tags, slug, draft flag and anything else the site needs. The Markdown Front Matter Extractor splits a file into its two halves: the YAML metadata, parsed into JSON, and the Markdown content with the front matter removed. Both are shown separately so you can copy whichever part you need.

What front matter looks like

A typical file starts like this:

---
title: Getting started
date: 2024-01-15
tags: [setup, install]
draft: false
---
# Getting started

The opening --- must be the very first line of the file and the block ends at the next line that is exactly ---. Everything in between is read as YAML.

What the result contains

After extraction, the Extracted Result card shows five fields:

FieldContents
has_front_mattertrue when a valid front matter block was found, otherwise false
metadata JSONThe YAML parsed into a JSON object, for example {"title": "Getting started", "draft": false}
raw_front_matterThe YAML text exactly as written, without the --- lines
content without front matterThe Markdown body, with leading blank lines removed
full JSONhas_front_matter, metadata, raw front matter and content combined in one JSON object

Two status cards summarise the result: Detection status shows "Front matter found" or "No front matter", and Metadata fields counts the top-level keys. The footer reports the size of the full JSON and the word count of the content.

How to extract front matter

  1. Paste a Markdown file into Input Markdown, or press Paste in the header. The footer shows its character and line counts.
  2. Press Extract. The button shows "Working" while the request is processed.
  3. Check Detection status. If it says "No front matter", read the troubleshooting tips below.
  4. Copy the part you need: Copy Raw YAML for the original metadata block, Copy Content for the body only, or Copy Full JSON for everything.
  5. Press Download JSON to save the full result as markdown-front-matter.json.

Copy Input copies your original text, and Clear resets the input and all result fields.

Server-side parsing

The YAML is parsed on this site's server with the Symfony YAML component, a widely used PHP parser. When you press Extract, your Markdown is sent to the server, split and parsed there, and the result is returned to your browser. Input is limited to 200,000 characters per request; larger files are rejected with an error. Do not paste files that contain secrets such as API keys in their front matter.

How YAML values come out in JSON

Most values convert the way you would expect: strings stay strings, true and false become booleans, numbers become numbers, lists become arrays and nested keys become nested objects. One case needs attention:

  • Unquoted dates become numbers. The parser turns a bare date such as date: 2024-01-15 into a Unix timestamp, so the metadata JSON shows 1705276800 instead of the date text. If you need the date as written, put it in quotes in your YAML, date: "2024-01-15", or read it from the raw front matter field, which always keeps the original text.

If the YAML has a syntax error, for example a bad indent or an unclosed quote, the block is still detected and raw_front_matter still holds the text, but the metadata JSON is left empty. That combination, "Front matter found" with 0 keys, is a reliable sign of invalid YAML.

Where this saves time

  • Migrating between site generators. Pull the metadata out of each post so you can map fields from one platform's naming to another.
  • Feeding a CMS or database. The full JSON is easy to import, with metadata and body already separated.
  • Checking a post before publishing. Confirm the title, tags and draft flag parse the way your site generator will read them.
  • Cleaning content for reuse. Copy the body without front matter to paste into an editor, an email or a word counter.
  • Debugging build errors. When a static site build fails on one file, the empty metadata result quickly shows whether the YAML is at fault.

Troubleshooting "No front matter"

  • Make sure the very first characters of the file are --- followed by a line break. A blank line, a space or an invisible byte order mark before it prevents detection.
  • Make sure the closing --- sits on its own line and is followed by a line break. A file that ends immediately after the closing dashes, with nothing after them, is not detected; add a newline or a line of content.
  • Use three hyphens. TOML front matter between +++ lines and JSON front matter are not supported.
  • An empty block with nothing between the two --- lines is not detected.

Raw YAML or parsed JSON: which to copy

Copy the raw YAML when you are moving a post to another YAML-based site generator, because it keeps comments, quoting and key order exactly as written. Copy the metadata JSON, or the full JSON, when the destination is a script, an API or a database that expects structured data. If the two disagree, for example a date that turned into a number, trust the raw YAML as the record of what the author wrote.

Things to avoid

  • Do not rely on the metadata JSON for unquoted dates; use the raw YAML or quote the value.
  • Do not assume the content field is untouched: leading blank lines after the front matter are trimmed.
  • Do not paste confidential configuration. The text is processed on the server.
  • Do not expect the tool to fix YAML. It reports what parses and keeps the raw text; correcting errors is up to you.

Limitations

  • YAML front matter only, delimited by --- at the very top of the file.
  • Invalid YAML produces empty metadata rather than an error message pointing to the problem line.
  • Unquoted dates are converted to Unix timestamps in the metadata JSON.
  • Input is capped at 200,000 characters and needs a network connection.
  • One file at a time; there is no batch mode.

Related tools

To create a new front matter block from form fields rather than read one, use the Markdown Metadata Generator. To list the headings in the body you just extracted, try the Markdown Heading Extractor.

Frequently Asked Questions

Veelgestelde vragen

Korte antwoorden op de vragen die gebruikers stellen voordat ze het resultaat vertrouwen.

YAML front matter between two lines of three hyphens at the very top of the file. TOML front matter with plus signs and JSON front matter are not supported.

The YAML parser converts unquoted dates into Unix timestamps. Quote the date in your YAML, or copy it from the raw front matter field, which keeps the original text.

The YAML could not be parsed, usually because of a wrong indent, a tab character or an unclosed quote. The raw YAML is still shown so you can find and fix the problem.

The first line must be exactly three hyphens with nothing before it, and the closing three hyphens must be followed by a line break. Blank lines, spaces or a byte order mark at the top stop detection.

No. The Markdown is sent to this site's server, where the YAML is parsed, and the result is returned to your browser.

Yes. Each request can contain up to 200,000 characters. Larger input is rejected with an error message.

The file markdown-front-matter.json holds has_front_matter, the parsed metadata, the raw front matter text and the content without front matter.

Reacties (0)

Voor gebruikersdiscussies, uitzonderingsgevallen en aanvullende tips.
Laat een reactie achter
Je reactie wordt na het versturen openbaar weergegeven.
Nog geen reacties. Wees de eerste die reageert!
Laat het ons weten!
Een probleem met deze tool melden

Beschrijf het probleem dat u bent tegengekomen, zodat we dit kunnen onderzoeken en de tool kunnen verbeteren.

Wat helpt het meest?
Vermeld de invoer, het verwachte resultaat, het daadwerkelijke resultaat, de browser/het apparaat en, indien nuttig, een schermafbeelding.
Met de knop ‘Screenshot’ wordt een afbeelding van de pagina in de browser gemaakt en wordt de gegenereerde afbeelding aan dit formulier toegevoegd.
Screenshot van een volledige pagina
Vastgelegd in je browser met newisty.
Er is nog geen screenshot gemaakt.
Hulpmiddel Verslag