pydantic-numpy
Pydantic Model integration of the NumPy array
Decision gist · record as of 2026-08-14
Yes. The package is actively maintained, has no known vulnerabilities, low install friction, and solves a real gap in Pydantic's NumPy support. It's suitable for production use if you need to validate and serialize NumPy arrays within Pydantic models. The permissive BSD-3-Clause license poses no restriction.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Requires Python 3.11 or later (supports current versions, <3.15).
- Low friction install with five runtime dependencies (pydantic, numpy, ruamel-yaml, compress-pickle, semver).
- Active maintenance with a release 13 days ago; repo is not archived and has recent commits.
License · maintenance · safety
BSD-3-Clause (permissive) — BSD-3-Clause is permissive; you can use, modify, and distribute this package with minimal restrictions in commercial or open-source projects.
last release 2026-08-01 (13 days) · last repo commit 2026-08-13 · 52 stars
0 known vulnerabilities (OSV.dev, 2026-08-14) · 178,398 downloads/mo, #10,194 on PyPI
Alternatives
Verify before relying
pip install pydantic-numpy
import numpy as np
from pydantic import BaseModel
import pydantic_numpy.typing as pnd
class MyModel(BaseModel):
array: pnd.Np1DArrayFp64
model = MyModel(array=np.array([1.5, 2.5, 3.5]))
json_str = model.model_dump_json()
restored = MyModel.model_validate_json(json_str)- Whether custom serialization functions can handle all array types and edge cases you need.
- Performance characteristics when working with very large arrays or deeply nested structures.
- Compatibility with all Pydantic v2 features beyond the examples shown.
What it is and what it does
pydantic-numpy bridges NumPy arrays and Pydantic's validation and serialization framework. It provides typed annotations (like NpNDArrayFp64 for 3D float64 arrays) that work with both BaseModel and dataclass, plus a NumpyModel class for seamless dump/load of arrays to disk. You can instantiate models from raw arrays, NumPy .npy files, or .npz files with keys, and serialize to JSON with full schema compliance.
The package handles the impedance mismatch between NumPy's array semantics and Pydantic's type system by wrapping arrays in validated fields. It supports custom serialization, dimension constraints, dtype specification, and model-agnostic loading when multiple models might match. Runtime dependencies are minimal and well-established (pydantic, numpy, ruamel-yaml, compress-pickle, semver).
Use it for
- Validate and serialize machine-learning model inputs/outputs that include NumPy arrays as Pydantic models.
- Define strict dtype and dimension requirements for arrays in data pipelines (e.g., float32 1D arrays only).
- Persist Pydantic models containing arrays to disk and reload them with automatic type checking.
- Generate JSON schemas for APIs that accept or return NumPy array data.
- Combine NumPy arrays with other Pydantic fields in a single validated data structure.
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
Yes.
The package is actively maintained, has no known vulnerabilities, low install friction, and solves a real gap in Pydantic's NumPy support. It's suitable for production use if you need to validate and serialize NumPy arrays within Pydantic models. The permissive BSD-3-Clause license poses no restriction.
Install
pydantic-numpy on PyPI
Before you install
Low friction install with five runtime dependencies (pydantic, numpy, ruamel-yaml, compress-pickle, semver). Active maintenance with a release 13 days ago; repo is not archived and has recent commits.
Requires Python 3.11 or later (supports current versions, <3.15).
License in practice
BSD-3-Clause is permissive; you can use, modify, and distribute this package with minimal restrictions in commercial or open-source projects.
Quickstart
pip install pydantic-numpy
import numpy as np
from pydantic import BaseModel
import pydantic_numpy.typing as pnd
class MyModel(BaseModel):
array: pnd.Np1DArrayFp64
model = MyModel(array=np.array([1.5, 2.5, 3.5]))
json_str = model.model_dump_json()
restored = MyModel.model_validate_json(json_str)
Verify before relying
- Whether custom serialization functions can handle all array types and edge cases you need.
- Performance characteristics when working with very large arrays or deeply nested structures.
- Compatibility with all Pydantic v2 features beyond the examples shown.
Package facts
| License | BSD-3-Clause permissive |
| Python support | Supports the current Python release <3.15,>=3.11 |
| Install friction | Low. Pure-Python wheel |
| Runtime dependencies | 5 packagescompress-pickleruamel-yamlnumpypydanticsemver |
| Maintenance | Actively maintained 13 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 178,398 / month, #10,194 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
| Classifiers | Development Status :: 5 - Production/StableOperating System :: OS IndependentTopic :: Software Development :: Libraries :: Python Modules |
Evidence: pydantic_numpy-9.0.2-py3-none-any.whl
Tags
Let your AI agent find packages like this
Example. Real query, live index.
You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.
wish › “pydantic numpy integration”
- pydantic-numpyIntegrates NumPy arrays into Pydantic models with type validation,…
- kumo-apikumo-api defines RESTful API resource schemas as Pydantic dataclasses…
- numpydanticNumpydantic adds type annotations and validation for arrays with…
Give your agent the search over MCP, or paste the wish link into any chat.
More Python Modules packages
Converts domain names between Unicode and ASCII-compatible encoding (Punycode) according to IDNA 2008 and Unicode Technical Standard 46, with security validation and broader script coverage than the standard library.
Install it if you work with internationalized domain names, need to validate domains, or use HTTP clients that depend on it transitively.
Setuptools is a Python build backend and package management tool that handles building, distributing, and installing Python packages, including support for C/C++ extension modules.
PyYAML parses and emits YAML 1.1 data format, enabling serialization and deserialization of configuration files and Python objects to and from human-readable YAML text.
Pydantic validates Python data structures against type hints, coercing and checking input at runtime to ensure it matches a declared schema.
Provides reusable metadata objects for use with PEP-593 `typing.Annotated` to express common constraints like bounds, collection sizes, and predicates on types.
Install it if you use or build libraries that need to express type constraints in a standardized, inspectable way—or if you want to annotate your own types with…
Provides runtime tools to inspect and introspect Python type annotations, enabling programmatic examination of type hints at execution time.
See also numpydantic · pydantic-collections · pydantic_yaml · pydantic-zarr · pydantic-to-typescript2 · drf-pydantic · pydantic-scim · pydantic-to-typescript · data-science-types · Flask-Pydantic