In Python, you often need to dump and load objects based on the schema you have. It can be a dataclass model, a list of third-party generic classes or whatever. Mashumaro not only lets you save and load things in different ways, but it also does it super quick.
Key features * 🚀 One of the fastest libraries * ☝️ Mature and time-tested * 👶 Easy to use out of the box * ⚙️ Highly customizable * 🎉 Built-in support for JSON, YAML, TOML, MessagePack * 📦 Built-in support for almost all Python types including typing-extensions * 📝 JSON Schema generation
debug config optioncode_generation_options config optionserialization_strategy config optionaliases config optionserialize_by_alias config optionallow_deserialization_not_by_alias config optionomit_none config optionomit_default config optionnamedtuple_as_dict config optionallow_postponed_evaluation config optiondialect config optionorjson_options config optiondiscriminator config optionlazy_compilation config optionsort_keys config optionforbid_extra_keys config optionThis library provides two fundamentally different approaches to converting your data to and from various formats. Each of them is useful in different situations:
Codecs are represented by a set of decoder / encoder classes and decode / encode functions for each supported format. You can use them to convert data of any python built-in and third-party type to JSON, YAML, TOML, MessagePack or a basic form accepted by other serialization formats. For example, you can convert a list of datetime objects to JSON array containing string-represented datetimes and vice versa.
Mixins are primarily for dataclass models. They are represented by mixin classes that add methods for converting to and from JSON, YAML, TOML, MessagePack or a basic form accepted by other serialization formats. If you have a root dataclass model, then it will be the easiest way to make it serializable. All you have to do is inherit a particular mixin class.
In addition to serialization functionality, this library also provides JSON Schema builder that can be used in places where interoperability matters.
Use pip to install:
$ pip install mashumaro
The current version of mashumaro supports Python versions 3.10 — 3.14.
It's not recommended to use any version of Python that has reached its
end of life and is no longer receiving
security updates or bug fixes from the Python development team.
For convenience, there is a table below that outlines the
last version of mashumaro that can be installed on unmaintained versions
of Python.
| Python Version | Last Version of mashumaro | Python EOL |
|---|---|---|
| 3.9 | 3.20 | 2025-10-31 |
| 3.8 | 3.14 | 2024-10-07 |
| 3.7 | 3.9.1 | 2023-06-27 |
| 3.6 | 3.1.1 | 2021-12-23 |
This project follows the principles of Semantic Versioning. Changelog is available on GitHub Releases page.
There is support for generic types from the standard typing module:
* List
* Tuple
* NamedTuple
* Set
* FrozenSet
* Deque
* Dict
* OrderedDict
* DefaultDict
* TypedDict
* Mapping
* MutableMapping
* Counter
* ChainMap
* Sequence
for standard generic types on PEP 585:
* list
* tuple
* namedtuple
* set
* frozenset
* collections.abc.Set
* collections.abc.MutableSet
* collections.deque
* dict
* collections.OrderedDict
* collections.defaultdict
* collections.abc.Mapping
* collections.abc.MutableMapping
* collections.Counter
* collections.ChainMap
* collections.abc.Sequence
* collections.abc.MutableSequence
for special primitives from the typing module:
* Any
* Optional
* Union
* TypeVar
* TypeVarTuple
* NewType
* Annotated
* Literal
* LiteralString
* Final
* Self
* Unpack
* ReadOnly
for standard interpreter types from types module:
* NoneType
* UnionType
* MappingProxyType
for enumerations based on classes from the standard enum module:
* Enum
* IntEnum
* StrEnum
* [Flag](ht
$ claude mcp add mashumaro \
-- python -m otcore.mcp_server <graph>