MCPcopy Index your code
hub / github.com/Fatal1ty/mashumaro

github.com/Fatal1ty/mashumaro @v3.22

Chat with this repo
repository ↗ · DeepWiki ↗ · release v3.22 ↗ · + Follow
2,081 symbols 9,575 edges 148 files 7 documented · 0% 1 cross-repo links
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

logo

Fast and well tested serialization library

Build Status Coverage status Latest Version Python Version License

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

Table of contents

Introduction

This library provides two fundamentally different approaches to converting your data to and from various formats. Each of them is useful in different situations:

  • Codecs
  • Mixins

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.

Installation

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

Changelog

This project follows the principles of Semantic Versioning. Changelog is available on GitHub Releases page.

Supported data types

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

Core symbols most depended-on inside this repo

from_dict
called by 438
mashumaro/mixins/dict.py
to_dict
called by 357
mashumaro/mixins/dict.py
type_name
called by 178
mashumaro/core/meta/helpers.py
build_json_schema
called by 173
mashumaro/jsonschema/builder.py
append
called by 158
mashumaro/core/meta/code/lines.py
get
called by 124
mashumaro/core/meta/types/common.py
get_args
called by 75
mashumaro/core/meta/helpers.py
decode
called by 70
mashumaro/codecs/basic.py

Shape

Class 836
Function 807
Method 437
Route 1

Languages

Python100%

Modules by API surface

tests/test_discriminated_unions/test_parent_via_config.py101 symbols
tests/test_jsonschema/test_jsonschema_generation.py97 symbols
tests/test_dialect.py93 symbols
tests/test_data_types.py89 symbols
mashumaro/core/meta/code/builder.py64 symbols
tests/test_types.py63 symbols
mashumaro/core/meta/types/unpack.py63 symbols
tests/entities.py62 symbols
tests/test_common.py60 symbols
tests/test_discriminated_unions/test_parent_by_field.py56 symbols
tests/test_meta.py55 symbols
mashumaro/core/meta/helpers.py55 symbols

Used by 1 indexed graphs manifest dependencies, hub-wide

For agents

$ claude mcp add mashumaro \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact