skillfed

marshmallow-mongoengine

Mongoengine integration with the marshmallow (de)serialization library

marshmallow-mongoengine v0.31.2 148.9K downloads/30d#11,012 on PyPI76
Permissive license MIT Active released

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-mongoengine

uv

uv add marshmallow-mongoengine

poetry

poetry add marshmallow-mongoengine

Installing 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

Intended Audience :: DevelopersLicense :: OSI Approved :: MIT LicenseNatural Language :: EnglishProgramming Language :: Python :: 3Programming Language :: Python :: 3.4Programming Language :: Python :: 3.5Programming Language :: Python :: 3.6Programming Language :: Python :: 3.7Programming Language :: Python :: 3.8

Tags

mongoengine marshmallow integrationserialize mongoengine documentsmongodb schema validationmongoengine to json serializationmarshmallow mongoengine schemasdocument serialization mongodb
mongodb-serializationschema-generation

More Database packages

psycopg2-binary

psycopg2-binary is a PostgreSQL database…

copyleft · top 1,000 on PyPI

redis

Python client library for connecting to and…

permissive · top 1,000 on PyPI

ydb

YDB Python SDK is the official client library…

permissive · top 1,000 on PyPI

snowflake-connector-python

Connects Python applications to Snowflake data…

permissive · top 1,000 on PyPI

sqlparse

sqlparse tokenizes SQL text into a tree of…

permissive · top 1,000 on PyPI

dbt-adapters

Provides base adapter protocols and shared…

permissive · top 1,000 on PyPI

marshmallow-sqlalchemy

Generates marshmallow schemas from SQLAlchemy…

permissive · top 5,000 on PyPI

flask-mongoengine

Flask-MongoEngine integrates MongoEngine…

permissive · top 15,000 on PyPI

mongoengine

MongoEngine provides an Object-Document Mapper…

permissive · top 5,000 on PyPI

marshmallow-union

Adds union field support to marshmallow,…

permissive · top 5,000 on PyPI

marshmallow-oneofschema

Extends marshmallow to handle polymorphic…

permissive · top 5,000 on PyPI

marshmallow-jsonschema

Converts marshmallow schemas into JSON Schema…

permissive · top 5,000 on PyPI

marshmallow

Marshmallow converts complex Python objects to…

permissive · top 1,000 on PyPI

marshmallow-polyfield

Extends Marshmallow with a PolyField class that…

permissive · top 15,000 on PyPI

amundsen-common

Amundsen Common provides shared utilities and…

unclear · top 15,000 on PyPI

DeepFriedMarshmallow

Accelerates Marshmallow schema serialization…

permissive · top 15,000 on PyPI