numpyencoder
Python JSON encoder for handling Numpy data types.
What it is and what it does
numpyencoder is a lightweight JSON encoder that extends Python's standard json module to handle NumPy data types. When you try to serialize a NumPy array or scalar using the standard json.dump() or json.dumps(), you normally get a TypeError; this package provides a NumpyEncoder class that you pass as the cls parameter to transparently convert NumPy objects into JSON-serializable Python types.
The package depends on numpy and packaging. It's designed for workflows where you're working with NumPy arrays or calculations and need to write results to JSON files or transmit them over JSON APIs without writing custom conversion logic. The encoder integrates directly into Python's json module, so you use it by simply specifying cls=NumpyEncoder in your json.dump() call.
Use it for:
- Save NumPy computation results (arrays, statistics) to JSON configuration or data files
- Serialize machine learning model outputs or intermediate arrays for logging or API responses
- Convert NumPy-based scientific data to JSON for web APIs or inter-process communication
- Export numerical simulation or analysis results to JSON-compatible formats without manual type conversion
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Provides a custom JSON encoder class that serializes NumPy data types (arrays, scalars, etc.) to JSON-compatible formats, allowing NumPy objects to be written directly to JSON files without manual conversion.
Yes, if you regularly work with NumPy and need to serialize to JSON. The package is lightweight, has no known vulnerabilities, and uses a permissive license. Maintenance is aging (last release 395 days ago), so verify that it handles your specific NumPy types before relying on it for new projects; for established workflows it is a straightforward, low-risk addition.
Install
numpyencoder on PyPI
pip
pip install numpyencoderuv
uv add numpyencoderpoetry
poetry add numpyencoderInstalling numpyencoder
Before you install
Low friction installation with a pure-Python wheel. Maintenance is aging—last release was 395 days ago—but the repository remains active and the package has been stable since its 2018 initial release.
License in practice
MIT license is permissive; you may use, modify, and distribute this package freely in commercial and private projects with minimal restrictions.
Quickstart
import json
import numpy as np
from numpyencoder import NumpyEncoder
numpy_data = np.array([0, 1, 2, 3])
json.dumps(numpy_data, cls=NumpyEncoder)
Verify before relying
- Which specific NumPy data types are supported (e.g., all scalar types, structured arrays, datetime64)
- Performance characteristics when encoding large arrays or deeply nested NumPy structures
- Compatibility with NumPy versions beyond the current release cycle
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (>=3.6) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 2 — numpy, packaging |
| Maintenance | aging — 395 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 168,629/month — #10,442 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: numpyencoder-0.3.2-py3-none-any.whl
Keywords: numpy, json, encoder
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
json-numpyProvides lossless JSON encoding and decoding…
permissive · top 15,000 on PyPI
javapropertiesReads and writes Java .properties files in both…
permissive · top 5,000 on PyPI
pyjson5Parses and serializes JSON5 (a more lenient…
permissive · top 5,000 on PyPI
json-encoderProvides JSON serialization with…
unclear · top 15,000 on PyPI
msgpack-numpySerializes and deserializes NumPy arrays and…
permissive · top 5,000 on PyPI
jsonconversionConverts arbitrary Python objects to JSON…
permissive · top 5,000 on PyPI
jsonstreamsWrites JSON documents in a streaming format…
permissive · top 15,000 on PyPI
orjsonorjson is a fast JSON serialization and…
copyleft · top 1,000 on PyPI
jsonseqEncodes and decodes JSON text sequences…
permissive · top 15,000 on PyPI
standardjsonProvides a JSON encoder that handles datetime,…
permissive · top 15,000 on PyPI