json-numpy
JSON encoding/decoding for Numpy arrays and scalars
What it is and what it does
json-numpy extends Python's built-in json module to handle NumPy arrays and scalars, which the standard library cannot serialize natively. It provides three usage patterns: a drop-in replacement for json functions, explicit encoder/decoder functions for use with the standard json module, or monkey-patching to modify json behavior globally. The package preserves array shape, dtype, and values through the encode-decode cycle without data loss.
The package depends only on numpy and supports Python 3.8 through 3.13. It is classified as Production/Stable and has been maintained since its initial release in 2021. The implementation wraps the standard json module's methods, making it straightforward to integrate into existing codebases that already work with NumPy data.
Use it for:
- Serialize NumPy arrays to JSON for REST API responses or file storage
- Deserialize JSON data back into NumPy arrays in data processing pipelines
- Enable JSON-based inter-process communication when one process uses NumPy and another expects JSON
- Store numerical computation results as JSON while preserving array structure and dtype information
- Monkey-patch json in third-party libraries to transparently handle NumPy objects without code modification
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Provides lossless JSON encoding and decoding for NumPy arrays and scalars, with a drop-in replacement API for the standard json module.
Yes. The package solves a genuine gap in Python's standard library with low install friction, permissive licensing, and stable maintenance. It is well-suited for any workflow that needs to serialize NumPy data to JSON. The three usage patterns offer flexibility for different integration scenarios.
Install
json-numpy on PyPI
pip
pip install json-numpyuv
uv add json-numpypoetry
poetry add json-numpyInstalling json-numpy
Before you install
Low friction installation with a single runtime dependency on numpy. The package is marked as Production/Stable and has been actively maintained, with a recent release on 2025-06-30.
License in practice
MIT License permits unrestricted use, modification, and distribution with minimal restrictions—suitable for both open-source and proprietary projects.
Quickstart
import numpy as np
import json_numpy
arr = np.array([0, 1, 2])
encoded = json_numpy.dumps(arr)
decoded = json_numpy.loads(encoded)
Verify before relying
- Performance characteristics and memory overhead compared to alternative serialization formats for large arrays
- Compatibility with all NumPy scalar types and complex nested data structures
Package facts
| License | MIT License Copyright (c) 2021-2025 Crimson-Crow <github@crimsoncrow.dev> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation… (full text in the JSON record) (permissive) |
| Python support | supports the current Python release (>=3.8) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 1 — numpy |
| Maintenance | aging — 410 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 387,754/month — #7,042 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: json_numpy-2.1.1-py3-none-any.whl
Keywords: json, numpy, serialization, encode, decode, encoding, decoding
Tags
More Utilities packages
Converts domain names between Unicode and…
permissive · top 100 on PyPI
charset-normalizerDetects and normalizes text encoding from…
permissive · top 100 on PyPI
setuptoolsSetuptools is a Python build backend and…
permissive · top 100 on PyPI
pluggyPluggy provides a plugin system that lets you…
permissive · top 100 on PyPI
PygmentsPygments is a syntax highlighter that colorizes…
permissive · top 100 on PyPI
sixSix provides utility functions to write Python…
permissive · top 100 on PyPI
jsonconversionConverts arbitrary Python objects to JSON…
permissive · top 5,000 on PyPI
numpyencoderProvides a custom JSON encoder class that…
permissive · top 15,000 on PyPI
json-tricksExtends Python's JSON serialization to handle…
permissive · top 15,000 on PyPI
simplejsonsimplejson encodes Python objects to JSON and…
permissive · top 1,000 on PyPI
flask-orjsonReplaces Flask's default JSON encoder with…
permissive · top 15,000 on PyPI
msgpack-numpySerializes and deserializes NumPy arrays and…
permissive · top 5,000 on PyPI
msgpack-numpy-opentensorSerializes and deserializes NumPy arrays and…
permissive · top 15,000 on PyPI
asn1Encodes and decodes ASN.1 data structures using…
permissive · top 5,000 on PyPI
py-ubjsonEncodes and decodes data in Universal Binary…
permissive · top 5,000 on PyPI
jsonpicklejsonpickle converts complex Python objects to…
permissive · top 5,000 on PyPI