skillfed

numpyencoder

Python JSON encoder for handling Numpy data types.

numpyencoder v0.3.2 168.6K downloads/30d#10,442 on PyPI35
Permissive license MIT AGING released

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 numpyencoder

uv

uv add numpyencoder

poetry

poetry add numpyencoder

Installing 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

Operating System :: OS IndependentProgramming Language :: Python :: 3

Tags

numpy json encoderserialize numpy arrays to jsonjson encoder for numpynumpy data type serializationconvert numpy to jsonnumpy json compatibility
numpy-integrationjson-serialization

More Utilities packages