marshmallow-mongoengine
Mongoengine integration with the marshmallow (de)serialization library
What it is and what it does
marshmallow-mongoengine bridges mongoengine (a MongoDB ODM for Python) and marshmallow (a serialization/deserialization library) by automatically generating marshmallow schemas from mongoengine document models. Instead of manually writing schema definitions, you declare your mongoengine models and then wrap them in a ModelSchema class that inherits the field structure automatically. This eliminates repetition when you need to serialize mongoengine documents to JSON, validate incoming data, or deserialize it back into document instances.
The package handles the common workflow of MongoDB applications: define a mongoengine Document, create a corresponding schema, then use dump() to serialize instances and load() to deserialize and validate incoming data. It's particularly useful in REST APIs and other contexts where you need consistent validation and serialization of MongoDB documents without writing schema definitions twice.
Use it for:
- Building REST APIs backed by MongoDB that need automatic request/response serialization and validation
- Converting mongoengine documents to JSON for API responses without manual field mapping
- Validating incoming JSON data against mongoengine document structure before saving to MongoDB
- Reducing boilerplate by auto-generating marshmallow schemas from existing mongoengine models
- Handling nested document relationships (references, lists) in serialization workflows
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Generates marshmallow schemas automatically from mongoengine document models, enabling serialization and deserialization of MongoDB data with minimal boilerplate.
Yes, if you're already using mongoengine and marshmallow together. The package eliminates schema duplication and integrates cleanly with both libraries. However, note that the last release was 2023-03-14; verify compatibility with your specific versions of mongoengine and marshmallow before adopting, and monitor the repository for any compatibility issues with newer releases of those dependencies.
Install
marshmallow-mongoengine on PyPI
pip
pip install marshmallow-mongoengineuv
uv add marshmallow-mongoenginepoetry
poetry add marshmallow-mongoengineInstalling marshmallow-mongoengine
Before you install
Low friction install with only two runtime dependencies (mongoengine and marshmallow). Repository is active with a recent commit on 2026-08-01, though the last release was 2023-03-14, indicating the package is stable but not under active development.
License in practice
MIT licensed under a permissive license, allowing use in commercial and proprietary projects with minimal restrictions beyond attribution.
Quickstart
pip install marshmallow-mongoengine
import mongoengine as me
from marshmallow_mongoengine import ModelSchema
class Author(me.Document):
name = me.StringField()
class AuthorSchema(ModelSchema):
class Meta:
model = Author
author_schema = AuthorSchema()
author = Author(name='Test').save()
dump_data = author_schema.dump(author).data
Verify before relying
- Whether the package supports mongoengine versions released after 2023-03-14
- Compatibility with modern marshmallow versions and any breaking changes in recent releases
- Whether Python 3.9+ is supported despite classifiers only listing through 3.8
Package facts
| License | MIT (permissive) |
| Python support | not specified |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 2 — mongoengine, marshmallow |
| Maintenance | actively maintained — 1,249 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 148,926/month — #11,012 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: marshmallow_mongoengine-0.31.2-py2.py3-none-any.whl
Keywords: mongoengine, marshmallow
Tags
More Database packages
psycopg2-binary is a PostgreSQL database…
copyleft · top 1,000 on PyPI
redisPython client library for connecting to and…
permissive · top 1,000 on PyPI
ydbYDB Python SDK is the official client library…
permissive · top 1,000 on PyPI
snowflake-connector-pythonConnects Python applications to Snowflake data…
permissive · top 1,000 on PyPI
sqlparsesqlparse tokenizes SQL text into a tree of…
permissive · top 1,000 on PyPI
dbt-adaptersProvides base adapter protocols and shared…
permissive · top 1,000 on PyPI
marshmallow-sqlalchemyGenerates marshmallow schemas from SQLAlchemy…
permissive · top 5,000 on PyPI
flask-mongoengineFlask-MongoEngine integrates MongoEngine…
permissive · top 15,000 on PyPI
mongoengineMongoEngine provides an Object-Document Mapper…
permissive · top 5,000 on PyPI
marshmallow-unionAdds union field support to marshmallow,…
permissive · top 5,000 on PyPI
marshmallow-oneofschemaExtends marshmallow to handle polymorphic…
permissive · top 5,000 on PyPI
marshmallow-jsonschemaConverts marshmallow schemas into JSON Schema…
permissive · top 5,000 on PyPI
marshmallowMarshmallow converts complex Python objects to…
permissive · top 1,000 on PyPI
marshmallow-polyfieldExtends Marshmallow with a PolyField class that…
permissive · top 15,000 on PyPI
amundsen-commonAmundsen Common provides shared utilities and…
unclear · top 15,000 on PyPI
DeepFriedMarshmallowAccelerates Marshmallow schema serialization…
permissive · top 15,000 on PyPI