{"id":442,"library":"marshmallow","title":"Marshmallow","description":"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.","status":"active","version":"4.2.3","language":"python","source_language":"en","source_url":"https://github.com/marshmallow-code/marshmallow","tags":["serialization","deserialization","Python","ORM","ODM"],"install":[{"cmd":"pip install marshmallow","lang":"bash","label":"Install Marshmallow"}],"dependencies":[{"reason":"Recommended for robust datetime deserialization","package":"python-dateutil","optional":true}],"imports":[{"note":"Ensure correct import path to avoid ImportError.","symbol":"Schema","correct":"from marshmallow import Schema"},{"note":"Import fields from marshmallow to access various field types.","symbol":"fields","correct":"from marshmallow import fields"}],"quickstart":{"code":"from marshmallow import Schema, fields\n\nclass UserSchema(Schema):\n    name = fields.Str()\n    email = fields.Email()\n    created_at = fields.DateTime()\n\nuser_data = {\n    'name': 'Monty',\n    'email': 'monty@python.org',\n    'created_at': '2014-08-17T14:54:16.049594+00:00'\n}\n\nschema = UserSchema()\nresult = schema.load(user_data)\nprint(result)","lang":"python","description":"A simple example demonstrating how to define a schema and load data using Marshmallow."},"warnings":[{"fix":"Add 'ordered = True' in the Meta class of your schema.","message":"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.","severity":"breaking","affected_versions":"4.x"},{"fix":"Add 'unknown = INCLUDE' in the Meta class of your schema to include unknown fields.","message":"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.","severity":"gotcha","affected_versions":"4.x"}],"env_vars":null,"search_vec":"'2026':26 '28':25 '4.2.3':21 'approxim':35 'cadenc':32 'complex':9 'convert':8 'current':18 'datatyp':10,16 'deseri':40 'everi':36 'follow':28 'librari':6 'lightweight':5 'march':24 'marshmallow':1,2 'month':38 'nativ':14 'odm':43 'orm':42 'python':15,41 'regular':30 'releas':22,31 'serial':39 'updat':34 'version':19","created_at":"2026-03-28T12:02:46.265455+00:00","updated_at":"2026-04-16T16:26:49.954958+00:00","problems":[{"fix":"To fix this, either define the 'unknown' option in your Schema's `Meta` class to `EXCLUDE` or `INCLUDE`, or ensure your input data only contains fields explicitly defined in the schema.","cause":"This error occurs when the input data contains fields that are not defined in the Marshmallow schema.","error":"marshmallow.exceptions.ValidationError: {'field_name': ['Unknown field.']}"},{"fix":"Ensure that all fields marked as `required=True` in your schema are present in the data being loaded.","cause":"This error indicates that a required field, explicitly marked with `required=True` in your Marshmallow schema, was not provided in the input data during deserialization (`load` method).","error":"marshmallow.exceptions.ValidationError: {'field_name': ['Missing data for required field.']}"},{"fix":"Ensure you are using your Marshmallow schema's `.dump()` method to serialize complex Python objects into a dictionary of JSON-serializable types (like strings, numbers, booleans, lists, and dicts) before attempting to JSON-encode them with `jsonify` or `json.dumps()`. Alternatively, configure custom JSON encoders for specific types if not using Marshmallow for that particular object.","cause":"This error often occurs when trying to `jsonify` or directly JSON-encode a Python object (like a SQLAlchemy model instance or a `datetime` object) that Python's default `json` module or a framework's `jsonify` function doesn't know how to convert. Marshmallow's role is to serialize these into JSON-serializable types, but if the output of `schema.dump()` is not used or if non-serializable objects are passed directly to `jsonify` before Marshmallow processes them, this error will appear.","error":"TypeError: Object of type X is not JSON serializable"},{"fix":"When defining a list of nested objects in a Marshmallow schema, wrap the nested Schema class with `fields.Nested()`. For example, use `my_list_field = fields.List(fields.Nested(MyNestedSchema))`.","cause":"This error typically arises in Marshmallow when attempting to define a nested schema within a `fields.List` using `fields.List(MySchema)` instead of `fields.List(fields.Nested(MySchema))`. The `fields.List` expects a Field instance, and `fields.Nested` creates that instance from a Schema class.","error":"TypeError: 'type' object is not subscriptable"}],"ecosystem":"pypi","meta_description":null,"install_score":100,"quickstart_score":80,"quickstart_tag":"verified","pypi_latest":"4.3.0","cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/marshmallow-code/marshmallow","docs":null,"changelog":"https://marshmallow.readthedocs.io/en/latest/changelog.html","pypi":"https://pypi.org/project/marshmallow/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["serialization"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"passing","verified_at":"2026-06-28","last_verified":"2026-06-28","next_check":"2026-07-28","install_tag":"verified"}}