mf2py
Microformats parser
What it is and what it does
mf2py is a microformats parser that reads HTML and extracts structured data in JSON format. It recognizes microformats2 classes (like h-card, h-entry, h-event) and converts them into a standardized dictionary structure, making it easy to programmatically access semantic markup embedded in web pages. The library also supports the older microformats1 format and has experimental metaformats extraction.
You typically use mf2py when you need to consume or validate microformats-marked HTML—common in IndieWeb applications, social media integrations, and semantic web tooling. It accepts HTML from files, strings, or URLs, and returns a dict with items, relationships, and metadata. The three runtime dependencies (html5lib, requests, beautifulsoup4) handle the heavy lifting of HTML parsing and network fetching.
Use it for:
- Extract author and publication metadata from blog posts marked with h-entry and h-card microformats.
- Parse event listings (h-event) from calendar or conference websites to build aggregators or search indexes.
- Validate that your own HTML markup correctly implements microformats2 before publishing.
- Build IndieWeb applications that need to read contact cards (h-card) or social interactions (webmentions) from remote URLs.
- Convert microformats-annotated HTML into JSON for downstream processing or storage in a database.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
mf2py parses HTML documents to extract microformats2 data structures, with backwards compatibility for microformats1 and experimental metaformats support.
Yes, if you are working with microformats-marked HTML or building IndieWeb tooling. The package is stable, has no known vulnerabilities, and low install friction. However, dormant maintenance (980 days since last release) means you should not expect bug fixes or spec updates; use it only for stable, well-established microformats2 parsing tasks.
Install
mf2py on PyPI
pip
pip install mf2pyuv
uv add mf2pypoetry
poetry add mf2pyInstalling mf2py
Before you install
Low install friction with a pure-Python wheel and three common dependencies (html5lib, requests, beautifulsoup4). Maintenance is dormant—last release was 980 days ago—so expect no active bug fixes or feature updates, though the package has been stable since its 2014 inception.
License in practice
MIT license is permissive, allowing commercial and private use with minimal restrictions. You may use, modify, and distribute mf2py freely as long as you retain the license notice.
Quickstart
import mf2py
mf2json = mf2py.parse(doc="<div class='h-card'><p class='p-name'>Jane</p></div>")
print(mf2json['items'])
Requires Python 3.8 or later. The parser uses html5lib internally, so BeautifulSoup documents passed to it may be modified in place.
Verify before relying
- Whether dormant status (980 days since last release) affects real-world compatibility with current microformats2 specs or HTML5 parsing edge cases.
- Performance characteristics when parsing large or deeply nested HTML documents.
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (>=3.8) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 3 — html5lib, requests, beautifulsoup4 |
| Maintenance | dormant — 980 days since the last release |
| First released | |
| Downloads | 562,651/month — #5,986 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: mf2py-2.0.1-py3-none-any.whl
Tags
More HTML packages
MarkupSafe provides a text object that escapes…
permissive · top 100 on PyPI
Jinja2Jinja2 is a templating engine that renders…
permissive · top 100 on PyPI
beautifulsoup4Beautiful Soup parses HTML and XML documents…
permissive · top 100 on PyPI
lxmllxml provides Python bindings to libxml2 and…
permissive · top 1,000 on PyPI
docutilsDocutils converts plaintext documentation in…
unclear · top 1,000 on PyPI
MarkdownConverts Markdown text to HTML using a Python…
permissive · top 1,000 on PyPI
extructExtracts structured metadata from HTML markup…
permissive · top 15,000 on PyPI
html2docxConverts valid HTML to Microsoft Word (.docx)…
permissive · top 15,000 on PyPI
jira2markdownConverts JIRA markup text to Markdown…
permissive · top 15,000 on PyPI
BeautifulSoupBeautiful Soup parses HTML and XML documents…
permissive · top 15,000 on PyPI
img2tableIdentifies and extracts tables from images and…
permissive · top 15,000 on PyPI
hyperscriptHyperscript lets you generate HTML markup…
permissive · top 15,000 on PyPI
tinyhtml5Parses HTML5 documents—including malformed…
permissive · top 1,000 on PyPI
collate-dbt-artifacts-parserParses dbt artifact JSON files (catalog,…
permissive · top 15,000 on PyPI