{
 "kind": "tool",
 "slug": "gray-matter",
 "path": "tools/gray-matter/",
 "name": "gray-matter",
 "maker": null,
 "density": "profile",
 "crumbs": [
  [
   "Tools",
   "tools/"
  ],
  [
   "Markdown, editors and content",
   "tools/content-editors/"
  ]
 ],
 "lead": "Parser extracting YAML/JSON front matter from markdown and text files.",
 "chips": [
  {
   "label": "Markdown, editors and content",
   "path": "tools/content-editors/"
  },
  {
   "label": "NPM"
  }
 ],
 "primary": {
  "label": "Copy install command",
  "copy": "npm install gray-matter"
 },
 "links": [
  {
   "label": "GitHub",
   "href": "https://github.com/jonschlinkert/gray-matter"
  },
  {
   "label": "Website",
   "href": "https://github.com/jonschlinkert/gray-matter"
  }
 ],
 "track": "New versions, deprecation and license changes on your dashboard",
 "verdicts": [
  {
   "key": "license",
   "label": "License",
   "value": "MIT",
   "status": "yes",
   "sub": "Use it in paid apps",
   "quote": null,
   "note": "License from npm.",
   "src": "https://github.com/jonschlinkert/gray-matter"
  },
  {
   "key": "maint",
   "label": "Maintained",
   "value": "Quiet for a year",
   "status": "cond",
   "sub": "Last change Jun 14, 2025",
   "note": "",
   "src": "https://github.com/jonschlinkert/gray-matter"
  },
  {
   "key": "pop",
   "label": "Used by agents' projects",
   "value": "98 projects",
   "status": "info",
   "sub": "#5 of 149 in its category",
   "note": "Dependency in 98 public GitHub projects set up for AI coding agents that we scanned (1.6%).",
   "src": null
  },
  {
   "key": "agent",
   "label": "Agent access",
   "value": "Install only",
   "status": "info",
   "sub": null,
   "note": "Agent skills for this library in the skills catalog; community skills are written by others, read them before you install.",
   "src": null
  }
 ],
 "vfoot": "From the package registry and GitHub, checked daily.",
 "blocks": [
  {
   "id": "overview",
   "nav": "Overview",
   "h2": "What gray-matter does",
   "parts": [
    {
     "t": "prose",
     "text": "gray-matter does one small job: it splits a file into a <code>data</code> object and a <code>content</code> string, without regex, and can write the data back out as front matter."
    }
   ]
  },
  {
   "id": "popularity",
   "nav": "Popularity",
   "h2": "gray-matter popularity",
   "parts": [
    {
     "t": "stats",
     "items": [
      {
       "n": "67",
       "of": "/ 100",
       "l": "Gid Score, #565 overall"
      },
      {
       "n": "15.4M",
       "l": "downloads a week, npm"
      },
      {
       "n": "4,498",
       "l": "GitHub stars"
      },
      {
       "n": "98",
       "l": "agent projects use it"
      }
     ]
    },
    {
     "t": "small",
     "text": "Gid Score measures public popularity and activity, not quality.",
     "link": "How the Gid Score is calculated",
     "path": "tools/top/"
    }
   ]
  },
  {
   "id": "usage",
   "nav": "How it is used",
   "h2": "How gray-matter is used",
   "parts": [
    {
     "t": "list",
     "items": [
      "gray-matter is a dependency in 98 of the 6,258 public GitHub projects set up for AI coding agents that we scanned (2.0% of the 4,867 JavaScript/TypeScript ones), #5 of 149 in markdown, editors and content.",
      "Counting the projects our scan samples by dependency (Solana 3,067, Ethereum and EVM 1,774, 3D and games 3,130, agent frameworks and SDKs 13,750), it appears in 247; those are left out of every share on this page.",
      "Projects that use it most often also use Next.js (56.1%), remark-gfm (40.8%), TypeScript (94.9%)."
     ]
    },
    {
     "t": "h3",
     "text": "By coding agent"
    },
    {
     "t": "rows",
     "rows": [
      {
       "l": "69 projects, 2.1%",
       "v": "Claude Code",
       "path": "agents/claude-code/"
      },
      {
       "l": "43 projects, 1.8%",
       "v": "Cursor",
       "path": "agents/cursor/"
      },
      {
       "l": "40 projects, 1.3%",
       "v": "GitHub Copilot",
       "path": "agents/github-copilot/"
      },
      {
       "l": "13 projects, 2.7%",
       "v": "Gemini CLI",
       "path": "agents/gemini-cli/"
      },
      {
       "l": "10 projects, 2.9%",
       "v": "OpenCode",
       "path": "agents/opencode/"
      },
      {
       "l": "10 projects, 2.1%",
       "v": "OpenAI Codex",
       "path": "agents/openai-codex/"
      },
      {
       "l": "6 projects, 2.2%",
       "v": "Devin Desktop",
       "path": "agents/devin-desktop/"
      }
     ]
    },
    {
     "t": "h3",
     "text": "Often used with"
    },
    {
     "t": "rows",
     "rows": [
      {
       "l": "In 56.1% of its projects",
       "v": "Next.js",
       "path": "tools/next/"
      },
      {
       "l": "In 40.8% of its projects",
       "v": "remark-gfm",
       "path": "tools/remark-gfm/"
      },
      {
       "l": "In 94.9% of its projects",
       "v": "TypeScript",
       "path": "tools/typescript/"
      },
      {
       "l": "In 65.3% of its projects",
       "v": "React",
       "path": "tools/react/"
      },
      {
       "l": "In 30.6% of its projects",
       "v": "react-markdown",
       "path": "tools/react-markdown/"
      },
      {
       "l": "In 48.0% of its projects",
       "v": "clsx",
       "path": "tools/clsx/"
      },
      {
       "l": "In 61.2% of its projects",
       "v": "Tailwind CSS",
       "path": "tools/tailwindcss/"
      },
      {
       "l": "In 48.0% of its projects",
       "v": "Lucide React",
       "path": "tools/lucide-react/"
      }
     ]
    }
   ]
  },
  {
   "id": "profile",
   "nav": "Profile",
   "h2": "gray-matter in practice",
   "parts": [
    {
     "t": "h3",
     "text": "Strengths"
    },
    {
     "t": "rows",
     "rows": [
      {
       "l": "One call, two fields",
       "v": "The main function takes a string and returns an object. Most code only needs <code>data</code> and <code>content</code> from it."
      },
      {
       "l": "Not fooled by example front matter in code blocks",
       "v": "The maintainers chose not to parse with regex. They list fenced code blocks that contain sample YAML front matter as a case that other parsers get wrong."
      },
      {
       "l": "Writes front matter back out",
       "v": "<code>matter.stringify</code> turns an object back into a front matter block and puts it in front of the content. The README notes this is useful for linting and for updating properties."
      },
      {
       "l": "Language picked from the opening fence",
       "v": "If you write <code>---toml</code> as the first delimiter, gray-matter uses the TOML engine for that file without any options being set."
      }
     ]
    },
    {
     "t": "h3",
     "text": "Watch out for"
    },
    {
     "t": "rows",
     "rows": [
      {
       "l": "Only YAML and JSON stringify out of the box",
       "v": "Writing TOML or other formats back requires an engine that supplies its own <code>stringify</code> method."
      },
      {
       "l": "Excerpt separator defaults to <code>---</code>",
       "v": "With <code>excerpt: true</code>, the excerpt ends at the next <code>---</code>. The excerpt also stays inside <code>content</code>. Set <code>excerpt_separator</code> if your body uses <code>---</code> for other things."
      },
      {
       "l": "<code>matter.read</code> is synchronous",
       "v": "The file helper blocks while it reads from disk. For async code, read the file yourself and pass the string to <code>matter()</code>."
      }
     ]
    },
    {
     "t": "h3",
     "text": "Parse a string with front matter"
    },
    {
     "t": "tabs",
     "label": "Example",
     "items": [
      {
       "tab": "Js",
       "code": "const matter = require('gray-matter');\nconsole.log(matter('---\\ntitle: Home\\n---\\nOther stuff'));\n//=> { data: { title: 'Home'}, content: 'Other stuff' }"
      }
     ]
    }
   ]
  },
  {
   "id": "more",
   "nav": null,
   "spy_as": "profile",
   "h2": "More about gray-matter",
   "parts": [
    {
     "t": "more",
     "items": [
      {
       "title": "Funding",
       "path": "tools/funding/",
       "items": [
        "GitHub Sponsors: https://github.com/jonschlinkert",
        "16 GitHub sponsors"
       ]
      },
      {
       "title": "Packages around it",
       "items": [
        "next: React framework",
        "remark-gfm: GitHub Markdown for remark",
        "typescript: Typed JavaScript",
        "react: UI library",
        "clsx: className helper",
        "react-markdown: Markdown to React"
       ]
      },
      {
       "title": "More in Markdown, editors and content",
       "path": "tools/content-editors/",
       "items": [
        {
         "text": "react-markdown",
         "path": "tools/react-markdown/"
        },
        {
         "text": "remark-gfm",
         "path": "tools/remark-gfm/"
        },
        {
         "text": "Marked",
         "path": "tools/marked/"
        },
        {
         "text": "Jinja2",
         "path": "tools/jinja2/"
        },
        {
         "text": "Tiptap",
         "path": "tools/tiptap/"
        },
        {
         "text": "Shiki",
         "path": "tools/shiki/"
        },
        {
         "text": "highlight.js",
         "path": "tools/highlight-js/"
        },
        {
         "text": "markdown-it",
         "path": "tools/markdown-it/"
        }
       ]
      }
     ]
    }
   ]
  },
  {
   "id": "alternatives",
   "nav": "Alternatives",
   "h2": "Alternatives",
   "parts": [
    {
     "t": "alts",
     "items": [
      {
       "name": "gray-matter",
       "me": true,
       "facts": [
        "MIT",
        "Gid 67",
        "15.4M/wk"
       ]
      }
     ],
     "more": "Compare gray-matter with another tool",
     "more_path": "tools/compare/"
    }
   ]
  },
  {
   "id": "start",
   "nav": "Get started",
   "h2": "Get started",
   "parts": [
    {
     "t": "install",
     "intro": "Install it.",
     "code": "npm install gray-matter"
    },
    {
     "t": "h3",
     "text": "Rules for your agent"
    },
    {
     "t": "rules",
     "label": "Paste into AGENTS.md or CLAUDE.md",
     "text": "## gray-matter\n- Import with `const matter = require('gray-matter')`, or in TypeScript with `import * as matter from 'gray-matter'`.\n- Read metadata from `file.data` and the body from `file.content`. `orig`, `language`, `matter` and `stringify` are non-enumerable debug properties.\n- Use `delimiters`, `language` and `engines`. Do not use the deprecated `delims`, `lang` and `parsers`.\n- To update metadata, call `matter.stringify(content, data)`. Only YAML and JSON stringify by default; other formats need an engine with a `stringify` method.\n- `matter.read(filepath)` is synchronous. In async code, read the file yourself and pass the string to `matter()`.\n- When using `excerpt: true`, set `excerpt_separator` if the body may contain `---`. The excerpt is not removed from `content`.\n- Check `file.isEmpty` or call `matter.test(str)` before relying on `data` fields.\n"
    }
   ]
  }
 ],
 "glance": [
  [
   "Package",
   "npm gray-matter"
  ],
  [
   "Category",
   "Markdown, editors and content"
  ],
  [
   "License",
   "MIT"
  ],
  [
   "Latest version",
   "4.0.3, April 24, 2021"
  ],
  [
   "On GitHub since",
   "January 2014"
  ],
  [
   "Gid Score",
   "66.7"
  ],
  [
   "Rank in category",
   "#5 of 149"
  ],
  [
   "GitHub",
   "jonschlinkert/gray-matter"
  ],
  [
   "Last change",
   "Jun 14, 2025"
  ]
 ],
 "good": [
  "Used by metalsmith, Gatsby, Netlify, Assemble, as listed by the source; we have not checked each one."
 ],
 "checked_line": "From the package registry, GitHub and our scan of public agent projects; numbers update daily.",
 "logo": "https://agentgid.com/media/avatars/jonschlinkert.png"
}