Registry / serialization / marshmallow-jsonschema

marshmallow-jsonschema

JSON →
library0.16.0pypypi✓ verified 22d ago

marshmallow-jsonschema translates marshmallow schemas into JSON Schema Draft v7 compliant jsonschema. It enables developers to generate JSON Schemas directly from their existing Marshmallow schemas, which is particularly useful for frontend form generation, API documentation, or validation in other systems. The current version is 0.13.0, released in October 2021, suggesting a maintenance rather than a rapid release cadence.

pip install marshmallow-jsonschema
INSTALL
IMPORT
SIG · MARSHMALLOW-JSONSC
M
marshmallow-jsonschema
serializationpythonv0.16.0
Install
1.7s avg
Import
615ms
Disk
17MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.16.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.620s · 18.9MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 1.7s · import 0.610s · 19MB
17MB installed
● package 17MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

JSONSchema
from marshmallow_jsonschema import JSONSchema

This quickstart demonstrates how to define a basic Marshmallow schema and then use `marshmallow-jsonschema` to convert it into a JSON Schema representation. The output is a standard JSON Schema dictionary, ready for use in other applications.

from marshmallow import Schema, fields from marshmallow_jsonschema import JSONSchema class UserSchema(Schema): username = fields.String(required=True, metadata={'description': 'The user\'s unique identifier'}) age = fields.Integer(required=False, allow_none=True, metadata={'minimum': 0}) email = fields.Email(required=True) # Instantiate the JSONSchema converter json_schema_converter = JSONSchema() # Convert your Marshmallow schema to a JSON Schema dictionary user_json_schema = json_schema_converter.dump(UserSchema()) import json print(json.dumps(user_json_schema, indent=2))
Debug
Known issues
breaking`marshmallow-jsonschema` is not compatible with `marshmallow.fields.Enum` introduced in Marshmallow v3.18.0. Using this field type will result in an `UnsupportedValueError`.
fix
Avoid using `marshmallow.fields.Enum` or consider using the `marshmallow-jsonschema-3` fork which addresses this and other OpenAPI/JSON Schema 3.x features. Alternatively, implement custom field handling for enums.
affects: marshmallow-jsonschema < 0.14.0 with marshmallow >= 3.18.0
deprecatedWhen used with newer Marshmallow versions (e.g., v4.x), `marshmallow-jsonschema` may produce `RemovedInMarshmallow4Warning` warnings related to deprecated field attributes like `default` (use `dump_default`) and passing field `metadata` as keyword arguments (use explicit `metadata=` argument).
fix
These are warnings from Marshmallow itself, not `marshmallow-jsonschema`. While the library might still function, upgrading `marshmallow-jsonschema` to a version that properly supports Marshmallow 4.x is the long-term solution. For now, ensure your Marshmallow schemas follow the latest best practices for field definition.
affects: marshmallow-jsonschema < 0.14.0 with marshmallow >= 4.0.0
gotcha`marshmallow-jsonschema` only supports converting Marshmallow schemas *to* JSON Schema. There is no built-in functionality to generate a Marshmallow schema *from* an existing JSON Schema.
fix
If you need to generate Marshmallow schemas from JSON Schema, you will need to use a different tool or implement a custom solution. This library is strictly a one-way conversion tool.
affects: All versions
Errors
Common errors & fixes
marshmallow_jsonschema.exceptions.UnsupportedValueError: unsupported field type <fields.Enum(...)>
marshmallow-jsonschema version 0.13.0 does not natively support the `marshmallow.fields.Enum` field type, particularly when used with Marshmallow versions 3.18.0 or higher.
fix
Avoid using `marshmallow.fields.Enum` directly. Instead, implement a custom field with a `_jsonschema_type_mapping` method, or consider using the `marshmallow-jsonschema-3` fork which provides updated compatibility.
RemovedInMarshmallow4Warning
This warning occurs when marshmallow-jsonschema 0.13.0 is used with Marshmallow 4.x, as the library's fixed version uses deprecated attributes or patterns from older Marshmallow versions.
fix
While marshmallow-jsonschema 0.13.0 might still function, the long-term solution is to use a `marshmallow-jsonschema` version that officially supports Marshmallow 4.x (if one becomes available). Alternatively, pin your `marshmallow` dependency to a version less than 4.0.
ModuleNotFoundError: No module named 'jsonschema.compat'
The `jsonschema` library, a dependency of `marshmallow-jsonschema`, removed the `jsonschema.compat` module in its 4.0 release. If `marshmallow-jsonschema` or another library relies on this removed module, this error will occur when `jsonschema` version 4.0 or higher is installed.
fix
Pin your `jsonschema` dependency to a version less than 4.0 by running `pip install 'jsonschema<4.0'`.
ModuleNotFoundError: No module named 'marshmallow_jsonschema'
The `marshmallow-jsonschema` package is not installed in your Python environment, or the environment where the code is being run does not have access to the installed package.
fix
Install the library using pip: `pip install marshmallow-jsonschema`. Ensure you are installing it into the correct Python environment.
Upgrade
Version history
0.16.0latest on PyPI · released Apr 26, 2026
Audit
Dependencies
marshmallowrequiredCore dependency for defining schemas to be converted.
Agent activity
3 hits · last 30 days
node
2
Resources
marshmallow-jsonschema — pip install marshmallow-jsonschema · libregistry