python-frontmatter
Parse and manage posts with YAML (or other) frontmatter
What it is and what it does
Python Frontmatter is a lightweight parser for documents that combine structured metadata (front matter) with body content, separated by delimiters. It reads files or text containing YAML (or other format) metadata blocks followed by content, and exposes them as separate, easily accessible objects—metadata as a dictionary and content as a string. The package handles common workflows: loading from files or file-like objects, parsing raw text, accessing metadata fields as dictionary keys, modifying metadata, and writing the combined document back to text or file format.
It's built for static site generators, documentation systems, and any workflow where you need to attach structured metadata to plain-text documents. The single runtime dependency is pyyaml, and it supports Python 3.10 and later. The package is actively maintained and has been stable since its early releases.
Use it for:
- Parse Jekyll or Hugo blog posts that use YAML front matter for metadata like title, date, and tags
- Extract and modify document metadata in static site generators or documentation pipelines
- Build content management workflows where metadata and body are stored together in plain text
- Process Markdown files with structured headers for automation or indexing
- Strip and rewrite front matter in batch document transformations
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Parses and manages text files with YAML (or JSON, TOML) front matter, separating structured metadata from document content for easy access and manipulation.
Yes. Low install friction, no security vulnerabilities, MIT license, active maintenance, and a single stable dependency make this a safe choice. Install it if you work with front-matter-delimited documents (Jekyll posts, static site content, or similar). Skip it only if your workflow doesn't involve parsing metadata-prefixed text files.
Install
python-frontmatter on PyPI
pip
pip install python-frontmatteruv
uv add python-frontmatterpoetry
poetry add python-frontmatterInstalling python-frontmatter
Before you install
Low friction: pure Python wheel with a single runtime dependency (pyyaml). Active maintenance with a recent release (86 days ago) and 427 repository stars.
License in practice
MIT license permits unrestricted use, modification, and distribution with only attribution required—no restrictions on commercial or proprietary use.
Quickstart
import frontmatter
post = frontmatter.load('document.txt')
print(post['title']) # access metadata
print(post.content) # access body content
# Or parse from text:
metadata, content = frontmatter.parse(text)
Verify before relying
- Whether JSON, TOML, and other front matter formats are equally well-supported or if YAML is the primary use case
- Performance characteristics when processing large files or batch operations
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (>=3.10) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 1 — pyyaml |
| Maintenance | actively maintained — 86 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 19,580,081/month — #1,060 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: python_frontmatter-1.3.0-py3-none-any.whl
Keywords: frontmatter
Tags
More Markup packages
PyYAML parses and emits YAML 1.1 data format,…
permissive · top 100 on PyPI
markdown-it-pyA Python markdown parser that converts markdown…
permissive · top 100 on PyPI
beautifulsoup4Beautiful Soup parses HTML and XML documents…
permissive · top 100 on PyPI
et-xmlfileet_xmlfile writes large XML files with minimal…
permissive · top 1,000 on PyPI
tomlkitParses and edits TOML files while preserving…
permissive · top 1,000 on PyPI
docstring-parserParses Python docstrings in ReST, Google,…
permissive · top 1,000 on PyPI
mdformat-front-mattersA plugin for mdformat that normalizes YAML,…
permissive · top 15,000 on PyPI
mdformat-frontmattermdformat-frontmatter is an mdformat plugin that…
permissive · top 5,000 on PyPI
parse-errorsWraps parse and validation errors from JSON,…
permissive · top 15,000 on PyPI
pytomlParses and writes TOML configuration files with…
permissive · top 15,000 on PyPI
f90nmlf90nml reads, writes, and modifies Fortran…
permissive · top 15,000 on PyPI
yaml-rsA high-performance YAML v1.2 parser for Python,…
permissive · top 15,000 on PyPI
tree-sitter-yamlA tree-sitter parser grammar for YAML files…
permissive · top 5,000 on PyPI
yteYTE is a YAML template engine that embeds…
permissive · top 15,000 on PyPI
whatthepatchParses and applies patch files in multiple diff…
permissive · top 5,000 on PyPI
pyymlEmbeds Python expressions directly in YAML…
permissive · top 15,000 on PyPI