skillfed

json-numpy

JSON encoding/decoding for Numpy arrays and scalars

json-numpy v2.1.1 387.8K downloads/30d#7,042 on PyPI23
Permissive 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) AGING released

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-numpy

uv

uv add json-numpy

poetry

poetry add json-numpy

Installing 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

Development Status :: 5 - Production/StableIntended Audience :: DevelopersIntended Audience :: Science/ResearchLicense :: OSI Approved :: MIT LicenseOperating System :: OS IndependentProgramming Language :: Python :: 3Programming Language :: Python :: 3 :: OnlyProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9Topic :: Utilities

Tags

numpy json serializationjson encode numpy arraysnumpy array to jsonserialize numpy datajson numpy encoder decodernumpy json conversionjson numpy compatibility
numpy-integrationserialization

More Utilities packages