msgspec
A fast serialization and validation library, with builtin support for JSON, MessagePack, YAML, and TOML.
Install
msgspec on PyPI
pip
pip install msgspecuv
uv add msgspecpoetry
poetry add msgspecPackage facts
| License | BSD-3-Clause (permissive) |
| Python support | supports the current Python release (>=3.10) |
| Install friction | medium — platform-specific wheel |
| Runtime dependencies | none |
| Maintenance | actively maintained — 123 days since the last release |
| Last repo commit | |
| First released | |
| Popularity | one of the top 1,000 most-downloaded packages on PyPI (30-day window, as of 2026-08-13) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-13) |
Evidence: msgspec-0.21.1-cp310-cp310-macosx_10_9_x86_64.whl; msgspec-0.21.1-cp310-cp310-macosx_11_0_arm64.whl; msgspec-0.21.1-cp310-cp310-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl; msgspec-0.21.1-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl; msgspec-0.21.1-cp310-cp310-musllinux_1_2_aarch64.whl; msgspec-0.21.1-cp310-cp310-musllinux_1_2_x86_64.whl; msgspec-0.21.1-cp310-cp310-win_amd64.whl; msgspec-0.21.1-cp310-cp310-win_arm64.whl; msgspec-0.21.1-cp311-cp311-macosx_10_9_x86_64.whl; msgspec-0.21.1-cp311-cp311-macosx_11_0_arm64.whl; msgspec-0.21.1-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl; msgspec-0.21.1-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl; msgspec-0.21.1-cp311-cp311-musllinux_1_2_aarch64.whl; msgspec-0.21.1-cp311-cp311-musllinux_1_2_x86_64.whl; msgspec-0.21.1-cp311-cp311-win_amd64.whl; msgspec-0.21.1-cp311-cp311-win_arm64.whl; msgspec-0.21.1-cp312-cp312-macosx_10_13_x86_64.whl; msgspec-0.21.1-cp312-cp312-macosx_11_0_arm64.whl; msgspec-0.21.1-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl; msgspec-0.21.1-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Keywords: JSON, MessagePack, TOML, YAML, msgpack, schema, serialization, validation
About msgspec
from the package's own PyPI description — quoted content, verbatim
<p align="center"> <a href="https://jcristharif.com/msgspec/"> <picture> <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/jcrist/msgspec/main/docs/_static/msgspec-logo-dark.svg"> <source media="(prefers-color-scheme: light)" srcset="https://raw.githubusercontent.com/jcrist/msgspec/main/docs/_static/msgspec-logo-light.svg"> <img src="https://raw.githubusercontent.com/jcrist/msgspec/main/docs/_static/msgspec-logo-light.svg" width="35%" alt="msgspec"> </picture> </a> </p>
<div align="center">
CI (image) Documentation (image) License (image) PyPI Version (image) Conda Version (image) [![Code...
Read as markdown · JSON record · Source repository · Homepage
AI interpretation — verify before relying
AI-generated interpretation of the package facts above; every digit, version, license, or vulnerability id it cites is grounded in the facts already shown on this page
msgspec is a fast serialization and validation library supporting JSON, MessagePack, YAML, and TOML with zero-cost schema validation using Python type annotations and a high-performance Struct type for structured data.
Medium install friction due to compiled wheels for multiple Python versions and platforms (3.10–3.14, x86_64/arm64, Linux/macOS/Windows), but no runtime dependencies and active maintenance (last commit 2026-08-12) reduce practical concern.
BSD-3-Clause (permissive) allows commercial and private use with minimal restrictions; attribution and license inclusion in distributions are the primary obligations.
Usage
import msgspec
class User(msgspec.Struct):
name: str
email: str | None = None
alice = User("alice", email="alice@example.com")
msg = msgspec.json.encode(alice)
decoded = msgspec.json.decode(msg, type=User)
Requires Python 3.10 or later; compiled wheels are provided for common platforms but source builds require a C compiler.
Verdict: msgspec is a mature, actively maintained serialization library (4007 GitHub stars, top 1000 PyPI tier) with no known vulnerabilities, permissive licensing, and zero runtime dependencies. Medium install friction is offset by comprehensive pre-built wheels and strong performance benchmarks. Suitable for production use where fast JSON/MessagePack handling and schema validation are priorities.
Needs verification
- Whether the compiled wheel for your specific platform (Python version + OS + architecture) is available in the distribution.
- Performance gains relative to your current serialization approach in your specific workload.
- Compatibility of msgspec's Struct type with existing dataclass or attrs codebases if migration is planned.
Similar packages
permissive · top 1,000 on PyPI
ujsonpermissive · top 1,000 on PyPI
mashumaropermissive · top 1,000 on PyPI
browser-usepermissive · top 1,000 on PyPI
duckdbpermissive · top 1,000 on PyPI
binaryornotpermissive · top 1,000 on PyPI
msgpackpermissive · top 1,000 on PyPI
djangorestframeworkpermissive · top 1,000 on PyPI
dataclasses-jsonpermissive · top 1,000 on PyPI
pydantic_corepermissive · top 100 on PyPI