python-mimeparse
A module provides basic functions for parsing mime-type names and matching them against a list of media-ranges.
What it is and what it does
Python-MimeParse is a lightweight utility for parsing and matching MIME types in HTTP content negotiation. It implements the media-range matching logic from RFC 7231 Section 5.3.2, allowing applications to determine which content type best satisfies a client's Accept header. The package provides functions to parse MIME types into components, extract quality parameters, and select the highest-quality match from a list of candidates.
It has no external runtime dependencies and supports Python 3.8 through 3.13 on both CPython and PyPy. The module is mature (first released in 2012) and actively maintained, making it a stable choice for any HTTP framework or API server that needs to negotiate content types with clients.
Use it for:
- REST API servers selecting response format (JSON vs XML vs HTML) based on client Accept headers
- Web frameworks implementing HTTP content negotiation during request routing
- Middleware that must parse and rank media-ranges to determine the best response encoding
- Testing HTTP clients that need to verify correct Accept header handling
- Proxy or gateway applications filtering or transforming responses by MIME type preference
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Parses and matches MIME types against media-ranges according to RFC 7231, determining quality scores for content negotiation in HTTP applications.
Yes. This is a stable, dependency-free utility for a standard HTTP task. Install it if your application handles content negotiation or needs to parse media-ranges; the low friction and active maintenance make it a safe choice. Skip it only if your framework already provides this functionality built-in.
Install
python-mimeparse on PyPI
pip
pip install python-mimeparseuv
uv add python-mimeparsepoetry
poetry add python-mimeparseInstalling python-mimeparse
Before you install
Low friction: pure Python wheel with no runtime dependencies. Actively maintained with recent commits and broad Python version support from 3.8 through 3.13 on both CPython and PyPy.
License in practice
MIT license permits unrestricted use, modification, and distribution with minimal restrictions—suitable for both open-source and commercial projects.
Quickstart
pip install python-mimeparse
import mimeparse
best = mimeparse.best_match(['application/json', 'text/html'], 'application/json, text/html;q=0.9')
Verify before relying
- Whether the package is actively developed beyond maintenance mode or if it is in stable-only status
- Real-world performance characteristics when matching against large lists of media-ranges
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (>=3.8) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | none |
| Maintenance | actively maintained — 719 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 865,700/month — #4,863 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: python_mimeparse-2.0.0-py3-none-any.whl
Keywords: mime-type, media-type
Tags
More Python Modules packages
Converts domain names between Unicode and…
permissive · top 100 on PyPI
setuptoolsSetuptools is a Python build backend and…
permissive · top 100 on PyPI
PyYAMLPyYAML parses and emits YAML 1.1 data format,…
permissive · top 100 on PyPI
pydanticPydantic validates Python data structures…
permissive · top 100 on PyPI
annotated-typesProvides reusable metadata objects for use with…
permissive · top 100 on PyPI
typing-inspectionProvides runtime tools to inspect and…
permissive · top 100 on PyPI
mediatypeParses and creates MIME types (media types)…
permissive · top 15,000 on PyPI
zope.contenttypeGuesses MIME types from filenames and body…
unclear · top 15,000 on PyPI
filetypeInfers file type and MIME type by examining…
permissive · top 1,000 on PyPI
rfc3339Formats and parses dates according to RFC 3339,…
unclear · top 5,000 on PyPI
rfc3987Provides RFC 3986 and RFC 3987 compliant…
copyleft · top 5,000 on PyPI
pyRFC3339Parses and generates RFC 3339-compliant…
permissive · top 5,000 on PyPI
mail-parserParses raw email messages into structured…
permissive · top 5,000 on PyPI
tikaTika-python provides Python access to Apache…
permissive · top 15,000 on PyPI
uritoolsParses, validates, and composes URIs and URI…
permissive · top 5,000 on PyPI
pyas2libBuilds and parses AS2 protocol messages with…
copyleft · top 15,000 on PyPI