Library / SDK
simplejson/simplejson avatar
simplejson/simplejson

simplejson: Extensible JSON Encoding and Decoding for Python

simplejson is a simple, fast, extensible JSON encoder/decoder for Python

1,710 stars371 forksPythonNOASSERTION

At a glance

What is it?
simplejson provides a dependency-free JSON implementation with an optional C extension, decoding hooks, and trusted pre-encoded JSON embedding. It fits Python applications that need serialization behavior beyond the ordinary built-in library.
Who is it for?
Adopt simplejson when an application needs its documented extension hooks, trusted RawJSON embedding, or optional compiled implementation. Do not replace the standard library for ordinary JSON without a concrete requirement.
Can I use it commercially?
Check first. The repository uses a licence we do not classify automatically, so read its LICENSE file before any commercial use.
Is it still maintained?
Yes. The repository last received commits 11 days ago.
What is it written in?
Mainly Python, according to GitHub's language statistics.

Answers come from the project's GitHub data, last synced on November 6, 2026, and from our analysis. They are not legal advice.

From daily snapshots

Star history

  • simplejson/simplejson1,710 ★ · -1
Star history
Repository2026-10-162026-11-06
simplejson/simplejson1.7k1.7k

-1 Stars in the last 21 days, measured from the daily GitHub snapshot. Compare with other projects

Editorial analysis

Why simplejson Extends Python JSON Handling

simplejson addresses Python applications that must serialize custom values or impose a richer structure on decoded JSON. Its encoder accepts a `default` callback, allowing a program to convert application objects without adding special serialization methods to those objects. The README describes this as similar in spirit to `pickle`, although simplejson remains a JSON encoder rather than a general Python object persistence format.

The decoder provides a different extension point. Its `object_hook` and `object_pairs_hook` arguments can post-process decoded objects. That makes the library relevant to protocols such as JSON-RPC, where the values inside a JSON document do not capture the protocol's full type system. The project targets Python 3.9 and newer while retaining Python 2.7 compatibility, which is useful only where legacy Python deployments still matter.

simplejson is also positioned as the externally maintained development version of the `json` library included with Python. The reason to choose it is therefore not merely the existence of another JSON parser. The relevant differences are its documented extension points, `RawJSON`, compatibility targets, and optional compiled component. An application that only needs ordinary JSON conversion may have little reason to introduce a separate serialization dependency and maintain a distinct serialization policy.

The project describes itself as a "simple, fast, complete, correct and extensible" encoder and decoder, but those general claims should not be treated as an adoption decision by themselves. Engineers need to identify which mechanism changes their application. That might be a conversion registry for domain objects, a decoder hook for JSON-RPC, or an already serialized fragment that should not be encoded twice. If none applies, the standard library is the more direct candidate.

Inside simplejson's Encoding and Decoding Flow

The normal encoding path accepts Python values and produces JSON. Values not handled by the standard conversion rules can be delegated to the function passed through `default`. This keeps serialization policy outside the classes being encoded. That arrangement suits a service that owns a conversion registry and does not want its domain classes to import or implement simplejson-specific behavior.

The callback receives values that the encoder cannot otherwise handle. Its return value becomes part of the JSON conversion process. That makes `default` appropriate for controlled application types, but it also puts application-defined serialization rules directly on the JSON output path. The README does not document a built-in registry class or additional schema validation layer, so developers should not assume that registering a callback introduces stricter validation elsewhere.

Decoding follows the normal JSON-to-Python path, after which `object_hook` can transform a decoded object. The `object_pairs_hook` alternative gives the callback access to an object's key-value pairs. The documentation specifically associates these hooks with JSON-RPC and richer type systems. The distinguishing design choice is post-processing rather than forcing every non-JSON domain type into the document format itself.

The encoder can also encounter `RawJSON`. Instead of treating its contents as an ordinary string and encoding that string again, simplejson inserts the supplied JSON text into the output. This can avoid redundant work when part of a payload has already been serialized. It also removes a validation boundary. The README warns that `RawJSON` bypasses normal serialization and validation, so its input should be fully trusted. Treating untrusted `RawJSON` content as safe would change the surrounding API from serialization of data to direct insertion into a JSON document.

simplejson Installation and a First RawJSON Use

The README does not include an explicit installation command. It directs users to the online documentation at `https://simplejson.readthedocs.io/` and identifies `simplejson` as a Python package with a legacy Python 2.7 wheel. Developers should obtain the release through the package source documented there rather than rely on an invented command or version constraint.

The repository's `pyproject.toml` declares its build requirements and backend:

toml
[build-system]
requires = ["setuptools>=42", "wheel"]
build-backend = "setuptools.build_meta"

This tells packagers how to build the project, but it is not a complete installation tutorial. After installing the package through the documented distribution route, the README provides this first `RawJSON` example:

python
from simplejson import dumps, RawJSON

payload = {
    "status": "ok",
    "data": RawJSON('{"a": 1, "b": 2}')
}

print(dumps(payload))
# Output: {"status": "ok", "data": {"a": 1, "b": 2}}

The embedded object should appear as JSON structure rather than as an escaped string. That is the central behavior of `RawJSON`, and also its risk. Correctness depends on the embedded text being valid and appropriately encoded JSON. The README explicitly says the feature is not recommended for general use unless the embedded content is fully trusted.

For normal encoding, the more relevant first use would be importing `dumps` and `loads` from `simplejson`, although the README excerpt does not present a separate minimal round-trip example. Engineers should resist copying the `RawJSON` example into a general-purpose API simply because it has a short and visually clear output. It demonstrates a specialized escape hatch, not the normal treatment of incoming data.

Optional C Extension and Python Compatibility Choices

The implementation is written in pure Python and has no dependencies, but the repository supports an optional C extension for what the README calls a "serious speed boost." This creates two deployment paths. A pure Python installation avoids requiring a C compiler at build or install time. An installation that includes the extension may offer faster encoding and decoding, but its suitability depends on the platform, build environment, and Python runtime used by the application.

The `setup.py` file defines `IS_PYPY` and `IS_GRAALPY` checks, while its classifiers name CPython, GraalPy, and PyPy implementations. It also records support across Python 3.9 through Python 3.15 and Python 2.7. The README states that the current development version is tested with Python 3.14, including free-threaded builds, and maintains backward compatibility with Python 3.9 and later.

That compatibility range matters for adoption. A team should verify the exact interpreter and implementation in its deployment rather than assuming that every listed classifier guarantees an identical binary-extension package. The pure Python design provides a path that does not depend on a compiled module, but the README excerpt does not document a universal runtime option for selecting it.

The repository also does not publish benchmark numbers. Claims about extension speed therefore cannot be converted into a workload-specific improvement without measurements from the adopting organization. The presence of `tsan_stress_simplejson.py` suggests attention to thread-sanitizer stress coverage, but its contents are not shown here, so it would be incorrect to infer exact concurrency guarantees from the filename. Engineers evaluating free-threaded Python should consult the release documentation and tests for the release they plan to deploy.

Where simplejson Is the Wrong Choice

An application that only needs standard JSON encoding and decoding may not need an extra dependency. Python’s built-in `json` also supports `default`, `object_hook` and `object_pairs_hook`; compare behavior for the target Python version before choosing a package. simplejson describes itself as the externally maintained development version of Python's built-in `json` library, so ordinary consumers should evaluate the built-in option before accepting another serialization dependency. The repository does not provide a comparison showing that every standard-library workload needs the alternative.

`RawJSON` also becomes the wrong choice at trust boundaries. It is useful when JSON has already been encoded and re-encoding is unnecessary, but the README says it bypasses serialization and validation. Embedding text from a client, database, or other untrusted source can allow that source to control part of the document without passing through the normal encoder. `RawJSON` is a targeted facility for fully trusted content, not a general data model.

A second limitation is the absence of documented integration with a schema system. The README describes JSON encoding and decoding, but it does not claim schema validation, protocol negotiation, or protection against malformed application-level objects. Those concerns still require separate design. An `object_hook` that constructs richer domain objects does not, by itself, establish a protocol's validation rules.

Legacy Python support creates another boundary. Python 2.7 support exists, but `setup.py` excludes Python 3.0 through 3.8. A modern service should check whether carrying a Python 2.7 path is a current requirement. The README also points to an older `python2.2` branch, but explicitly describes that fork as unmaintained and suitable only as a last resort. It should not be considered part of the current release path.

Upgrade planning also requires restraint. The README does not document rollback. A deployment should therefore identify the exact installed version and consult the project documentation before changing it in an environment where restoring the previous package automatically is a requirement.

simplejson Versus Python's Built-in json Library

The comparison starts with lineage and scope. simplejson is not a database, web framework, or validation layer. It is a replacement-oriented JSON encoder and decoder that tracks Python's built-in `json` library as an externally maintained development version. The project description explicitly highlights Python 2.7 legacy support, extensible serialization through `default`, decoder post-processing through `object_hook` or `object_pairs_hook`, and `RawJSON`.

The built-in Python `json` module supports ordinary parsing and serialization as well as `default`, `object_hook`, and `object_pairs_hook`. Evaluate simplejson when a feature such as `RawJSON`, its specific behavior, or compatibility with a target interpreter meets a concrete requirement. The difference is in processing model and compatibility surface, not in a documented replacement for the basic JSON document format.

Maintenance history is visible from the repository record. It is not archived, and its last push was on 2026-10-11. Recent releases include `v4.2.0` on 2026-10-03, `v4.1.2` on 2026-08-27, and `v4.1.1` on 2026-04-24. These dates show recent release activity, but they do not by themselves establish that every deployment risk is covered. The current setup identifies version `4.2.0`, so packaging and installed-version checks should be part of upgrade verification.

Licensing requires a separate file review. The repository identifies its license as a custom `LICENSE.txt` that GitHub cannot classify. The README excerpt does not state the grant, redistribution conditions, or warranty language. Users should read that file for the actual terms, especially in commercial or redistributed deployments, rather than treating the package description as a complete grant of rights.

The adoption boundary is fairly clear. Choose simplejson when one of its extensions is part of the design. Keep Python's built-in `json` module when the application only exchanges ordinary values and values compatibility with the existing standard-library import. First compare the required behavior and supported hooks on the target interpreter, then review `LICENSE.txt` and any compatibility requirements.

Editorial conclusion

Adopt simplejson when an application needs its documented extension hooks, trusted RawJSON embedding, or optional compiled implementation. Do not replace the standard library for ordinary JSON without a concrete requirement. First review LICENSE.txt, confirm that the target Python version and implementation are supported, and decide whether the deployment and trust boundaries permit RawJSON or require a compiled extension.

Frequently asked questions

What Python versions does simplejson support?

The README states support for Python 3.9 and newer, with legacy support for Python 2.7. The packaging metadata lists Python 3.9 through Python 3.15 and Python 2.7.

Does simplejson require external Python dependencies?

The README describes simplejson as pure Python code with no dependencies. It also includes an optional C extension for a speed improvement.

When should RawJSON be used in simplejson?

RawJSON embeds pre-encoded JSON without re-encoding it. The README says to use it only when the embedded content is fully trusted because it bypasses normal serialization and validation.

Official sources

  1. Issues
  2. Project website
  3. README
  4. Releases
  5. simplejson/simplejson on GitHub
Add this badge to your README

If you maintain this project, the badge below links readers to this analysis and shows its maintenance status from the daily GitHub snapshot. Paste the markdown into your README; add ?metric=license or ?metric=stars to the image URL for a different field.

Add this badge to your README

markdown
[![Hysen Labs](https://hysenlabs.com/badge/simplejson-simplejson.svg)](https://hysenlabs.com/projects/simplejson-simplejson)

Star history chart for your README

markdown
[![Star history](https://hysenlabs.com/chart/simplejson-simplejson.svg)](https://hysenlabs.com/projects/simplejson-simplejson)

Was this useful?