Project: remarkjs/remark-frontmatter

Package: remark-frontmatter@2.0.0

  1. Dependencies: 1·Dependents: 169
  2. remark plugin to support frontmatter (yaml, toml, and more)
  1. remark 204
  2. unified 155
  3. markdown 132
  4. plugin 131
  5. mdast 81
  6. remark-plugin 72
  7. frontmatter 5
  8. yaml 5
  9. toml 3


Build Coverage Downloads Size Sponsors Backers Chat

remark plugin to support frontmatter (YAML, TOML, and more).


This plugin is affected by the new parser in remark (micromark, see remarkjs/remark#536). Use version 2 while you’re still on remark 12. Use version 3 for remark 13+.



npm install remark-frontmatter


Say we have the following file, example.md:

title = "New Website"

# Other markdown

And our script, example.js, looks as follows:

var vfile = require('to-vfile')
var report = require('vfile-reporter')
var unified = require('unified')
var parse = require('remark-parse')
var stringify = require('remark-stringify')
var frontmatter = require('remark-frontmatter')

  .use(frontmatter, ['yaml', 'toml'])
  .process(vfile.readSync('example.md'), function (err, file) {
    console.error(report(err || file))

function logger() {
  return console.dir

Now, running node example yields:

  type: 'root',
  children: [
    {type: 'toml', value: 'title = "New Website"', position: [Object]},
    {type: 'heading', depth: 1, children: [Array], position: [Object]}
  position: {
    start: {line: 1, column: 1, offset: 0},
    end: {line: 6, column: 1, offset: 48}
example.md: no issues found
title = "New Website"

# Other markdown


remark().use(frontmatter[, options])

Configures remark so that it can parse and serialize frontmatter (YAML, TOML, and more).


See micromark-extension-frontmatter for a description of options.


Use of remark-frontmatter does not involve rehype (hast) or user content so there are no openings for cross-site scripting (XSS) attacks.


See contributing.md in remarkjs/.github for ways to get started. See support.md for ways to get help.

This project has a code of conduct. By interacting with this repository, organization, or community you agree to abide by its terms.


MIT © Titus Wormer