SQLAlchemy-JSONField
SQLALchemy JSONField implementation for storing dicts at SQL
What it is and what it does
SQLAlchemy-JSONField is a custom column type that abstracts away database-specific JSON handling differences. It lets you store Python dictionaries as JSON in your SQLAlchemy models while automatically choosing between native JSON support (PostgreSQL, modern MySQL, SQLite 3.9+) and text-encoded fallback (MariaDB, Percona, older SQLite). The package handles encoding/decoding transparently and lets you swap JSON libraries (e.g., ujson instead of the standard library json) or enforce string encoding when your database connector has Unicode limitations.
The main problem it solves is the fragmentation across test and production environments: you might test on SQLite but deploy on MySQL or PostgreSQL, and each has different JSON capabilities. Rather than writing conditional logic in your models, you define the field once with optional parameters like `enforce_string` and `enforce_unicode`, and the package adapts to whatever database is actually running.
Use it for:
- Store semi-structured data (nested dicts, lists) in SQLite during testing, then use native JSON in PostgreSQL production without code changes.
- Work around MariaDB's lack of native JSON support by automatically encoding to text while managing Unicode correctly.
- Use a faster JSON library like ujson for serialization/deserialization by passing it to the JSONField constructor.
- Migrate gradually from text-encoded JSON to native JSON as database versions are upgraded, without rewriting model definitions.
- Support multiple database backends in a single codebase where some have JSON and others require text fallback.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Provides a SQLAlchemy column type for storing dictionaries as JSON, with automatic fallback to text encoding for databases that lack native JSON support.
Yes. The package solves a real cross-database compatibility problem with low install friction (one dependency), active maintenance, no known vulnerabilities, and permissive licensing. It's useful if you need to store JSON-like data across heterogeneous database environments or want to swap JSON libraries. Skip it if you're locked into a single database with native JSON support and don't need encoding flexibility.
Install
sqlalchemy-jsonfield on PyPI
pip
pip install sqlalchemy-jsonfielduv
uv add sqlalchemy-jsonfieldpoetry
poetry add sqlalchemy-jsonfieldInstalling SQLAlchemy-JSONField
Before you install
Low friction: single runtime dependency on sqlalchemy, wheel distribution available. Active maintenance with recent release (95 days ago) and ongoing repository activity.
License in practice
Apache-2.0 permissive license allows commercial and private use with minimal restrictions.
Quickstart
import sqlalchemy_jsonfield
import sqlalchemy
class ExampleTable(Base):
__tablename__ = 'example'
id = sqlalchemy.Column(sqlalchemy.Integer, primary_key=True)
json_record = sqlalchemy.Column(
sqlalchemy_jsonfield.JSONField(enforce_string=True),
nullable=False
)
Requires Python 3.9 or later; sqlalchemy must be installed as a runtime dependency.
Verify before relying
- Whether the package works with SQLAlchemy 2.0+ (version constraint not specified in fact sheet)
- Performance characteristics when handling large JSON documents across different database backends
Package facts
| License | Apache-2.0 (permissive) |
| Python support | supports the current Python release (>=3.9.0) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 1 — sqlalchemy |
| Maintenance | actively maintained — 95 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 6,024,426/month — #1,982 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: sqlalchemy_jsonfield-1.0.3-py3-none-any.whl
Keywords: sql, sqlalchemy, json, jsonfield, development
Tags
More Python Modules packages
Converts domain names between Unicode and…
permissive · top 100 on PyPI
setuptoolsSetuptools is a Python build backend and…
permissive · top 100 on PyPI
PyYAMLPyYAML parses and emits YAML 1.1 data format,…
permissive · top 100 on PyPI
pydanticPydantic validates Python data structures…
permissive · top 100 on PyPI
annotated-typesProvides reusable metadata objects for use with…
permissive · top 100 on PyPI
typing-inspectionProvides runtime tools to inspect and…
permissive · top 100 on PyPI
pangresUpserts pandas DataFrames into PostgreSQL,…
permissive · top 15,000 on PyPI
sqlalchemy-jdbcapiSQLAlchemy dialect for JDBC and ODBC database…
permissive · top 15,000 on PyPI
django-jsonfieldProvides a JSONField for Django models that…
permissive · top 15,000 on PyPI
SQLAlchemy-UtcProvides a SQLAlchemy DateTime type that…
permissive · top 15,000 on PyPI
jsonfieldA Django model field that stores and retrieves…
permissive · top 5,000 on PyPI
django-sequencesProvides gapless sequence generation for Django…
permissive · top 15,000 on PyPI
sqlalchemy-jsonProvides mutation-tracked JSON column types for…
permissive · top 5,000 on PyPI
databasesProvides async database access for PostgreSQL,…
permissive · top 5,000 on PyPI
JSON-log-formatterFormats Python logging records as JSON,…
permissive · top 5,000 on PyPI
atlas-provider-sqlalchemyConnects SQLAlchemy models to Atlas to…
unclear · top 15,000 on PyPI