Marshmallow
Marshmallow is a lightweight library for converting complex datatypes to and from native Python datatypes. The current version is 4.2.3, released on March 28, 2026. It follows a regular release cadence, with updates approximately every few months.
Warnings
- breaking In Marshmallow 4.x, the 'load' method now returns a dictionary instead of an OrderedDict by default. To maintain the previous behavior, set the 'ordered' option to True in the schema's Meta class.
- gotcha The 'load' method in Marshmallow 4.x raises a ValidationError if it encounters unknown fields by default. To change this behavior, set the 'unknown' option in the schema's Meta class.
Install
-
pip install marshmallow
Imports
- Schema
from marshmallow import Schema
- fields
from marshmallow import fields
Quickstart
from marshmallow import Schema, fields
class UserSchema(Schema):
name = fields.Str()
email = fields.Email()
created_at = fields.DateTime()
user_data = {
'name': 'Monty',
'email': 'monty@python.org',
'created_at': '2014-08-17T14:54:16.049594+00:00'
}
schema = UserSchema()
result = schema.load(user_data)
print(result)