mashumaro 3.23


pip install mashumaro

  Latest version

Released: Sep 30, 2026


Meta
Author: Alexander Tikhonov
Requires Python: >=3.10

Classifiers

Intended Audience
  • Developers

Operating System
  • OS Independent

Programming Language
  • Python :: 3 :: Only
  • Python :: 3.10
  • Python :: 3.11
  • Python :: 3.12
  • Python :: 3.13
  • Python :: 3.14
  • Python :: 3.15

Development Status
  • 5 - Production/Stable
mashumaro

High-performance serialization without replacing your data model

Work with familiar Python data structures and type annotations. Mashumaro generates specialized encoders and decoders for them — no handwritten schemas or framework-specific models required.

Build Status Coverage status Latest Version Python Version License

Documentation · Benchmarks · Who uses mashumaro? · Releases

Why mashumaro?

  • Standard Python first. Keep ordinary dataclasses, collections, and type annotations; add a lightweight mixin only when you want methods on a model.
  • Fast by design. Mashumaro generates conversion code for the exact type shape instead of repeatedly inspecting it at runtime.
  • Broad typing support. Generics, unions, Annotated, Literal, TypedDict, NamedTuple, recursive models, and much more work recursively.
  • Two simple APIs. Add methods to a dataclass with a mixin, or create a reusable codec for any supported root type such as list[Event].
  • Use the format you already have. Convert to dictionaries, JSON, orjson, YAML, TOML, and MessagePack, and generate JSON Schema when you need it.

Mashumaro focuses on typed data conversion and serialization. It deliberately does not try to be a business-rule validation framework or replace your model layer.

Used across the Python ecosystem

Mashumaro is used by projects of all kinds, both directly and through other packages. Explore a selection from both groups below.

Featured projects using mashumaro directly

Music Assistant   SimpleFold   Flytekit   Nesso   pySmartThings   Vunnel   ESPHome Device Builder   MySkoda   dbt-common   HomeWizard Energy   TrueConf Bot   pxblat

Music Assistant · SimpleFold · Flytekit · Nesso · pySmartThings · Vunnel · ESPHome Device Builder · MySkoda · dbt-common · HomeWizard Energy · TrueConf Bot · pxblat

More projects and verification

More projects using mashumaro directly

Data and developer tools
Aligned · dbt-autofix · Flyte SDK

Science and machine learning
Allophant · Boltz · Patchr

Devices and web APIs
Bring API · Open-Meteo · pylamarzocco · PyMammotion · python-kasa · pyvesync · TikTokLive

and about 100 more projects

Featured projects using mashumaro indirectly

Prefect   dlt   LedFx   Dune Spellbook   sqruff   ZHA Device Handlers   dbt MCP   Recce   Dagster Open Platform   Databricks DQX   dbt-sqlserver   dbt-fabric

Prefect · dlt · LedFx · Dune Spellbook · sqruff · ZHA Device Handlers · dbt MCP · Recce · Dagster Open Platform · Databricks DQX · dbt-sqlserver · dbt-fabric

Data and dbt tooling
airflow-dbt-python · dbt-metabase · dbt-osmosis · dbt-score · dbterd

Connected-device integrations
Alexa Media Player · Better Thermostat · Hilo · Home Assistant MySkoda · Midea AC LAN · Powercalc · Spook · Toyota Connected Services

and about 500 more projects

Selection and verification

The September 30, 2026 snapshot paginated all 118 pages of the repository view of the GitHub dependency graph and cross-referenced its package view. It found 939 repositories with at least two stars; after excluding 36 forks, 903 remained. After verification, 125 had direct evidence in conventional dependency files and 11 more in unusual locations. Another 507 had only effective transitive evidence, while 259 could not be resolved.

Only exactly named dependency files in the repository root or directly under src/ are treated as conventional locations. GitHub's relationship is accepted for declaration files such as pyproject.toml, setup.py, setup.cfg, and requirements.in. Lockfiles and requirements snapshots that GitHub labels direct receive an additional content check. If another locked package depends on mashumaro and there is no edge from the local project, the relationship is reclassified as transitive. A requirements.txt entry is direct only when its own # via provenance points to an input declaration; freeze-style snapshots without per-entry provenance remain unresolved unless other evidence is conclusive. When a conventional dependency file has no recognizable GitHub relationship label, its contents are checked directly; an explicit declaration can still confirm direct use, while unreadable or ambiguous evidence fails closed as unresolved.

When GitHub's package view identifies a published package, its PyPI requires_dist metadata provides a second directness check. An explicit mashumaro requirement confirms direct use; a conclusive absence rejects the GitHub-direct result. Network and metadata failures are treated as inconclusive. Every project shown in the indirect usage sample therefore has only effective transitive relationships; unresolved repositories are counted but not featured.

For the gallery, each candidate was reviewed in context. A project was kept when mashumaro belongs to its maintained application, library, or clearly named product component. Repositories where the match came only from a demo, benchmark, test fixture, vendored copy, or generated dependency set were left out. This avoids presenting incidental development environments as product adoption.

Images are limited to organization marks from the reviewed repository data; projects under personal accounts are listed by name instead. Dependency data, repository activity, and ownership can change between snapshots. Logos belong to their respective projects, and inclusion does not imply endorsement.

Installation

pip install mashumaro

The current release supports Python 3.10–3.15. Install optional formats only when you need them:

pip install "mashumaro[orjson,yaml,toml,msgpack]"

See Migration and Compatibility for the last releases supporting older Python versions.

Quick start

Add serialization methods to a dataclass

from dataclasses import dataclass
from datetime import datetime

from mashumaro.mixins.json import DataClassJSONMixin


@dataclass
class Event(DataClassJSONMixin):
    name: str
    starts_at: datetime
    speakers: list[str]


event = Event(
    name="PyCon",
    starts_at=datetime(2026, 5, 13, 9, 0),
    speakers=["Alice", "Bob"],
)

payload = event.to_json()
restored = Event.from_json(payload)

assert restored == event

Nested dataclasses remain plain dataclasses; only the root model needs the mixin. Format-specific mixins for orjson, YAML, TOML, and MessagePack expose the same style of API.

Build a codec for any supported type shape

from mashumaro.codecs.json import JSONDecoder, JSONEncoder

encoder = JSONEncoder(list[Event])
decoder = JSONDecoder(list[Event])

payload = encoder.encode([event])
restored = decoder.decode(payload)

assert restored == [event]

Construct codecs once and reuse them when performance matters. A codec root can be a dataclass, collection, TypedDict, union, scalar, or another supported type shape.

Performance

Mashumaro generates specialized conversion functions once, then reuses them without repeatedly walking fields and annotations. The repository benchmark uses pyperf and a nested GitHub Issue model.

The results below were recorded on macOS 27.0.1, an Apple M3 Max, and Python 3.14.6. Lower is better; the charts use a logarithmic scale.

Deserialization benchmark Serialization benchmark

Benchmarks are workload- and configuration-dependent. Compare equivalent validation, conversion, and output semantics before drawing conclusions. See the performance guide for methodology and run ./benchmark/run.sh to reproduce the benchmark locally.

At a glance

Area Highlights
Models Dataclasses and recursively nested standard-library and typing constructs
APIs Mixins for dataclass models and reusable codecs for arbitrary supported type shapes
Outputs Basic Python values, JSON via the standard library or orjson, YAML, TOML, and MessagePack
Customization Field aliases, serialization strategies, custom and third-party types, dialects, hooks, discriminators, and omission rules
Schema generation JSON Schema Draft 2020-12 and OpenAPI 3.1

The full compatibility matrix and format-specific representations are documented in Supported Types and Supported Formats.

Where to go next

Browse the complete documentation for all chapters.

Contributing

Bug reports and pull requests are welcome. Please read the contributing guide and report security issues according to the security policy.

Mashumaro is distributed under the Apache License 2.0.

3.23 Sep 30, 2026
3.22 May 26, 2026
3.21 May 07, 2026
3.20 Feb 09, 2026
3.19 Feb 03, 2026
3.18 Jan 30, 2026
3.17 Oct 03, 2025
3.16 May 20, 2025
3.15 Nov 23, 2024
3.14 Oct 23, 2024
3.13.1 Jun 15, 2024
3.13 Apr 30, 2024
3.12 Jan 28, 2024
3.11 Nov 23, 2023
3.10 Sep 12, 2023
3.9.1 Aug 22, 2023
3.9 Aug 02, 2023
3.8.1 Jun 23, 2023
3.8 Jun 22, 2023
3.7 Apr 13, 2023
3.6 Apr 07, 2023
3.5 Feb 13, 2023
3.4 Feb 06, 2023
3.3.1 Jan 10, 2023
3.3 Dec 21, 2022
3.2 Dec 02, 2022
3.1.1 Nov 29, 2022
3.1 Oct 19, 2022
3.0.4 Aug 11, 2022
3.0.3 Jun 08, 2022
3.0.2 Jun 06, 2022
3.0.1 Apr 03, 2022
3.0 Feb 09, 2022
2.11 Jan 04, 2022
2.10.1 Dec 30, 2021
2.10 Dec 30, 2021
2.9.1 Dec 18, 2021
2.9 Nov 02, 2021
2.8 Oct 16, 2021
2.7 Sep 14, 2021
2.6.4 Sep 03, 2021
2.6.3 Aug 23, 2021
2.6.2 Aug 13, 2021
2.6.1 Aug 02, 2021
2.6 Jul 31, 2021
2.5 Apr 28, 2021
2.4 Apr 22, 2021
2.3 Apr 19, 2021
2.2 Apr 08, 2021
2.1 Apr 06, 2021
2.0.2 Mar 11, 2021
2.0.1 Mar 07, 2021
2.0 Mar 02, 2021
1.24 Feb 06, 2021
1.23 Jan 27, 2021
1.22 Jan 15, 2021
1.21 Jan 10, 2021
1.20 Jan 09, 2021
1.19 Jan 09, 2021
1.18 Jan 04, 2021
1.17 Dec 22, 2020
1.16 Dec 18, 2020
1.15 Nov 21, 2020
1.14 Nov 19, 2020
1.13 Sep 18, 2020
1.12 Dec 13, 2019
1.11 Dec 12, 2019
1.10 Dec 10, 2019
1.9 Nov 04, 2019
1.8 Oct 27, 2019
1.7 Jun 22, 2019
1.6.2 Mar 16, 2019
1.6.1 Feb 28, 2019
1.6 Feb 23, 2019
1.5 Feb 18, 2019
1.4 Jan 20, 2019
1.3 Jan 09, 2019
1.2.post1 Dec 12, 2018
1.2 Dec 12, 2018
1.1 Nov 27, 2018
1.0 Nov 27, 2018
0.9 Nov 26, 2018
0.8.1 Nov 26, 2018
0.8 Nov 26, 2018
0.7 Nov 26, 2018
0.6 Nov 23, 2018
0.5 Nov 23, 2018
0.4 Nov 03, 2018
0.3.1 Oct 30, 2018
0.3 Oct 30, 2018
0.2 Oct 29, 2018
0.1.3 Sep 25, 2018
0.1.2 Sep 17, 2018
0.1.1 Sep 11, 2018
0.1 Sep 11, 2018

Wheel compatibility matrix

Platform Python 3
any

Files in release

Extras:
Dependencies:
typing_extensions (>=4.14.0)