flask-marshmallow
Flask + marshmallow for beautiful APIs
What it is and what it does
Flask-Marshmallow is a lightweight bridge between Flask and marshmallow that simplifies building JSON APIs. It extends marshmallow with Flask-specific fields like URLFor and Hyperlinks, making it straightforward to generate HATEOAS-compliant responses where API resources include links to related endpoints. You define schemas as classes, then call dump() or load() on request/response data to serialize objects to JSON or deserialize incoming JSON back into Python objects with validation.
The package is designed for developers building REST APIs who want declarative, reusable schema definitions with automatic URL generation. It has no external system dependencies, installs quickly, and integrates cleanly into existing Flask applications. Optional integration with Flask-SQLAlchemy is available for ORM-backed schemas.
Use it for:
- Serialize database models to JSON responses with automatic hyperlinking to related endpoints.
- Validate and deserialize incoming JSON request bodies against defined schemas before processing.
- Generate HATEOAS-compliant API responses that include self and collection links.
- Define reusable output formats for multiple Flask routes sharing the same data model.
- Add email, datetime, and custom field validation to Flask request handlers.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Flask-Marshmallow integrates Flask and marshmallow to serialize/deserialize Python objects into JSON with built-in support for URL generation and HATEOAS hyperlinking in APIs.
Yes. Flask-Marshmallow is a mature, actively maintained library with no known vulnerabilities, minimal dependencies, and low install friction. It solves a common Flask use case (API serialization with validation) cleanly and is widely used (top 5000 packages by downloads). Install it if you're building a Flask API and want declarative schemas with built-in HATEOAS support.
Install
flask-marshmallow on PyPI
pip
pip install flask-marshmallowuv
uv add flask-marshmallowpoetry
poetry add flask-marshmallowInstalling flask-marshmallow
Before you install
Low friction: pure Python wheel with only two runtime dependencies (Flask and marshmallow). Active maintenance with a recent release and no known vulnerabilities.
License in practice
MIT license is permissive; you can use, modify, and distribute this package freely with minimal restrictions.
Quickstart
pip install flask-marshmallow
from flask import Flask
from flask_marshmallow import Marshmallow
app = Flask(__name__)
ma = Marshmallow(app)
class UserSchema(ma.Schema):
email = ma.Email()
_links = ma.Hyperlinks({"self": ma.URLFor("user_detail", values=dict(id=""))})
user_schema = UserSchema()
data = user_schema.dump({"email": "test@example.com"})
Requires Python 3.10 or later.
Verify before relying
- Whether Flask-SQLAlchemy integration is automatic or requires additional setup beyond what the excerpt shows.
- Performance characteristics when serializing large collections or deeply nested schemas.
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (>=3.10) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 2 — Flask, marshmallow |
| Maintenance | actively maintained — 120 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 1,535,427/month — #3,800 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: flask_marshmallow-1.5.0-py3-none-any.whl
Tags
More Dynamic Content packages
MarkupSafe provides a text object that escapes…
permissive · top 100 on PyPI
Jinja2Jinja2 is a templating engine that renders…
permissive · top 100 on PyPI
soupsieveSoupsieve is a CSS selector library designed to…
permissive · top 100 on PyPI
WerkzeugWerkzeug is a WSGI utility library providing…
permissive · top 1,000 on PyPI
FlaskFlask is a lightweight WSGI web application…
permissive · top 1,000 on PyPI
MakoMako compiles Python-embedded templates into…
permissive · top 1,000 on PyPI
amundsen-commonAmundsen Common provides shared utilities and…
unclear · top 15,000 on PyPI
Flask-JSONFlask-JSON adds convenient JSON response…
permissive · top 15,000 on PyPI
marshmallowMarshmallow converts complex Python objects to…
permissive · top 1,000 on PyPI
marshmallow-jsonapiProduces JSON API 1.0-compliant output from…
permissive · top 15,000 on PyPI
marshmallow-unionAdds union field support to marshmallow,…
permissive · top 5,000 on PyPI
APIFlaskAPIFlask is a lightweight web API framework…
permissive · top 15,000 on PyPI
marshmallow-jsonschemaConverts marshmallow schemas into JSON Schema…
permissive · top 5,000 on PyPI
marshmallow-sqlalchemyGenerates marshmallow schemas from SQLAlchemy…
permissive · top 5,000 on PyPI
marshmallow-oneofschemaExtends marshmallow to handle polymorphic…
permissive · top 5,000 on PyPI
webargswebargs parses and validates HTTP request…
permissive · top 5,000 on PyPI