{"id":51446087,"url":"https://github.com/crisp-oss/node-markdown-frontmatter-parser","last_synced_at":"2026-07-05T16:01:19.152Z","repository":{"id":366604934,"uuid":"1276991906","full_name":"crisp-oss/node-markdown-frontmatter-parser","owner":"crisp-oss","description":"A type-safe Markdown Frontmatter parser.","archived":false,"fork":false,"pushed_at":"2026-06-22T15:12:30.000Z","size":42,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2026-06-22T15:28:34.081Z","etag":null,"topics":["frontmatter","markdown","parser"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/markdown-frontmatter-parser","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/crisp-oss.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-06-22T13:34:52.000Z","updated_at":"2026-06-22T15:14:32.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/crisp-oss/node-markdown-frontmatter-parser","commit_stats":null,"previous_names":["crisp-oss/node-markdown-frontmatter-parser"],"tags_count":8,"template":false,"template_full_name":null,"purl":"pkg:github/crisp-oss/node-markdown-frontmatter-parser","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/crisp-oss%2Fnode-markdown-frontmatter-parser","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/crisp-oss%2Fnode-markdown-frontmatter-parser/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/crisp-oss%2Fnode-markdown-frontmatter-parser/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/crisp-oss%2Fnode-markdown-frontmatter-parser/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/crisp-oss","download_url":"https://codeload.github.com/crisp-oss/node-markdown-frontmatter-parser/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/crisp-oss%2Fnode-markdown-frontmatter-parser/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":35160046,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-07-05T02:00:06.290Z","response_time":100,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["frontmatter","markdown","parser"],"created_at":"2026-07-05T16:01:18.046Z","updated_at":"2026-07-05T16:01:19.144Z","avatar_url":"https://github.com/crisp-oss.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# node-markdown-frontmatter-parser\n\n[![Test and Build](https://github.com/crisp-oss/node-markdown-frontmatter-parser/actions/workflows/test.yml/badge.svg)](https://github.com/crisp-oss/node-markdown-frontmatter-parser/actions/workflows/test.yml) [![Build and Release](https://github.com/crisp-oss/node-markdown-frontmatter-parser/actions/workflows/build.yml/badge.svg)](https://github.com/crisp-oss/node-markdown-frontmatter-parser/actions/workflows/build.yml) [![NPM](https://img.shields.io/npm/v/markdown-frontmatter-parser.svg)](https://www.npmjs.com/package/markdown-frontmatter-parser) [![Downloads](https://img.shields.io/npm/dt/markdown-frontmatter-parser.svg)](https://www.npmjs.com/package/markdown-frontmatter-parser)\n\n**Markdown Frontmatter parser for Node. Can be used to extract metadata as key-value in Frontmatter headers in your Markdown files.**\n\nThis library was converted from Rust code, from the original library: [imbolc/markdown-frontmatter](https://github.com/imbolc/markdown-frontmatter). All credits for the original implementation go to the Rust `markdown-frontmatter` library.\n\n**🇵🇹 Crafted in Lisbon, Portugal.**\n\n## How to install?\n\nInclude `markdown-frontmatter-parser` in your `package.json` dependencies.\n\nAlternatively, you can run `npm install markdown-frontmatter-parser --save`.\n\n## How to use?\n\n### Parse a Markdown with Frontmatter\n\nExtract metadata and body from a markdown document. Returns `[{}, fullContent]` when no frontmatter is found. All metadata keys are lowercased.\n\nSupports YAML (`---`), TOML (`+++`), and JSON (`{`) frontmatter.\n\n```js\nimport { parse } from \"markdown-frontmatter-parser\";\n\nconst markdownWithFrontmatter = `---\ntitle: Hello World\ntags:\n  - news\n  - tech\n---\nBody content here.\n`;\n\nconst [headers, body] = parse(markdownWithFrontmatter);\n\nconsole.log(headers.title); // \"Hello World\"\nconsole.log(headers.tags);  // [\"news\", \"tech\"]\nconsole.log(body);          // \"Body content here.\\n\"\n```\n\n### Parse a Markdown with Frontmatter, with typed fields\n\nBy default, `parse` returns every value as-is from the raw frontmatter (a string stays a string, a number stays a number, etc.). If you need to force specific fields to a particular type — for example, a field that arrives as the string `\"42\"` but should be the number `42` — pass a `types` map as the second argument.\n\n**Available types:** `\"string\"`, `\"number\"`, `\"boolean\"`, or an array variant like `[\"string\"]`, `[\"number\"]`, `[\"boolean\"]` for fields that are lists.\n\n**Boolean casting** accepts: `true`/`false`, `\"true\"`/`\"false\"`, `\"yes\"`/`\"no\"`, `1`/`0`, `\"1\"`/`\"0\"`.\n\n**On cast failure**, a `TypeCastError` is thrown by default. Pass `throwing: false` to silently keep the original value instead.\n\n```js\nimport { parse } from \"markdown-frontmatter-parser\";\n\nconst doc = `---\ntitle: Hello World\ncount: \"42\"\nactive: \"yes\"\ntags:\n  - foo\n  - bar\nscores:\n  - \"10\"\n  - \"20\"\n---\nBody content here.\n`;\n\nconst [headers, body] = parse(doc, {\n  types: {\n    count:   \"number\",    // \"42\"   → 42\n    active:  \"boolean\",   // \"yes\"  → true\n    tags:    [\"string\"],  // already strings, no-op but explicit\n    scores:  [\"number\"],  // [\"10\", \"20\"] → [10, 20]\n  },\n});\n\nconsole.log(headers.count);   // 42\nconsole.log(headers.active);  // true\nconsole.log(headers.tags);    // [\"foo\", \"bar\"]\nconsole.log(headers.scores);  // [10, 20]\n\n// Keep original value when a cast fails, instead of throwing:\nconst [headers2] = parse(doc, {\n  types: { count: \"boolean\" }, // \"42\" can't be cast to boolean\n  throwing: false,             // → keeps \"42\" as-is\n});\n\nconsole.log(headers2.count); // \"42\"\n```\n\n### Generate Markdown and Frontmatter content from object\n\nSerialize metadata and content into a markdown string with a frontmatter header. Defaults to YAML format. A blank line is inserted between the header and the body.\n\n```js\nimport { generate } from \"markdown-frontmatter-parser\";\n\nconst doc = generate(\n  { title: \"Hello World\", tags: [\"news\", \"tech\"] },\n  \"Body content here.\\n\"\n);\n\n// ---\n// title: Hello World\n// tags:\n//   - news\n//   - tech\n// ---\n//\n// Body content here.\n\n// Pass a second format argument to use TOML or JSON instead:\nconst tomlDoc = generate({ title: \"Hello\" }, \"Body.\\n\", \"toml\");\n```\n\n### Lint a Markdown with Frontmatter (fixing it if needed)\n\nNormalize a markdown document by re-serializing its frontmatter in canonical form: keys lowercased, consistent delimiters, and a blank line between header and body. Returns the content unchanged when no frontmatter is detected.\n\nPass a `format` argument to convert to a different frontmatter format.\n\n```js\nimport { lint } from \"markdown-frontmatter-parser\";\n\nconst messy = `---\nTitle: Hello World\nTAGS: [news, tech]\n---\nBody content here.\n`;\n\nconsole.log(lint(messy));\n// ---\n// title: Hello World\n// tags:\n//   - news\n//   - tech\n// ---\n//\n// Body content here.\n\n// Convert YAML frontmatter to TOML:\nconsole.log(lint(messy, \"toml\"));\n// +++\n// title = \"Hello World\"\n// tags = [\"news\", \"tech\"]\n// +++\n//\n// Body content here.\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcrisp-oss%2Fnode-markdown-frontmatter-parser","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcrisp-oss%2Fnode-markdown-frontmatter-parser","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcrisp-oss%2Fnode-markdown-frontmatter-parser/lists"}