numpydantic
Type and shape validation and serialization for arbitrary array types in pydantic models
Decision gist · record as of 2026-08-14
Yes. Numpydantic is actively maintained, has no known vulnerabilities, and solves a real problem—pydantic's inability to validate arrays with shape and dtype constraints. Low install friction, permissive license, and support for multiple array backends make it a practical choice for data science and scientific computing workflows that use pydantic for validation.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Requires Python 3.10 or later; optional array-library extras (dask, hdf5, zarr, video) needed for those backends.
- Low friction: pure Python wheel with only three runtime dependencies (pydantic, numpy, typing-extensions).
- Actively maintained with a recent release 53 days ago and no known vulnerabilities.
License · maintenance · safety
MIT (permissive) — MIT license is permissive; you can use, modify, and distribute numpydantic freely in commercial and private projects with minimal restrictions.
last release 2026-06-22 (53 days) · last repo commit 2026-08-01 · 149 stars
0 known vulnerabilities (OSV.dev, 2026-08-14) · 602,059 downloads/mo, #5,817 on PyPI
Alternatives
Verify before relying
pip install numpydantic
from pydantic import BaseModel
from numpydantic import NDArray, Shape
import numpy as np
class MyModel(BaseModel):
array: NDArray[Shape["3 x, 4 y, * z"], int]
model = MyModel(array=np.zeros((3, 4, 5), dtype=int))- Whether the mypy plugin (introduced in 1.9.0) is production-ready and widely adopted.
- Performance overhead of validation on large arrays compared to raw numpy operations.
- Stability of the extensible specification syntax mentioned as planned for v2.
What it is and what it does
Numpydantic bridges the gap between pydantic's data validation and array libraries by letting you specify arrays with precise shape and dtype constraints in type annotations. It solves the problem that pydantic cannot natively validate numpy arrays or other array types without workarounds—numpydantic provides an NDArray type that works seamlessly in pydantic models while also supporting static type checking via a mypy plugin.
The package works with multiple array backends (numpy, dask, zarr, hdf5, video files) through a pluggable interface, so the same type annotation can validate arrays from different libraries. You can use NDArray outside pydantic too, for isinstance checks or as a callable validator. Serialization to JSON-compatible formats is built in, and the package generates correct JSON Schema for your models, making them interoperable.
Use it for
- Validate image or video data in pydantic models with exact shape and dtype requirements before processing.
- Define reusable array type aliases (e.g., GRAYSCALE) and catch shape mismatches at type-check time with mypy.
- Accept arrays from multiple backends (numpy, dask, zarr) in the same model without writing separate validators.
- Serialize array-containing models to JSON with metadata sufficient to reconstruct them in their native format.
- Lazy-load large arrays from hdf5 or zarr without full validation overhead by leveraging backend metadata.
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
Yes.
Numpydantic is actively maintained, has no known vulnerabilities, and solves a real problem—pydantic's inability to validate arrays with shape and dtype constraints. Low install friction, permissive license, and support for multiple array backends make it a practical choice for data science and scientific computing workflows that use pydantic for validation.
Install
numpydantic on PyPI
Before you install
Low friction: pure Python wheel with only three runtime dependencies (pydantic, numpy, typing-extensions). Actively maintained with a recent release 53 days ago and no known vulnerabilities.
Requires Python 3.10 or later; optional array-library extras (dask, hdf5, zarr, video) needed for those backends.
License in practice
MIT license is permissive; you can use, modify, and distribute numpydantic freely in commercial and private projects with minimal restrictions.
Quickstart
pip install numpydantic
from pydantic import BaseModel
from numpydantic import NDArray, Shape
import numpy as np
class MyModel(BaseModel):
array: NDArray[Shape["3 x, 4 y, * z"], int]
model = MyModel(array=np.zeros((3, 4, 5), dtype=int))
Verify before relying
- Whether the mypy plugin (introduced in 1.9.0) is production-ready and widely adopted.
- Performance overhead of validation on large arrays compared to raw numpy operations.
- Stability of the extensible specification syntax mentioned as planned for v2.
Package facts
| License | MIT permissive |
| Python support | Supports the current Python release <4.0,>=3.10 |
| Install friction | Low. Pure-Python wheel |
| Runtime dependencies | 3 packagespydanticnumpytyping-extensions |
| Maintenance | Actively maintained 53 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 602,059 / month, #5,817 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/StableFramework :: PydanticFramework :: Pydantic :: 2Intended Audience :: DevelopersIntended Audience :: Science/ResearchLicense :: OSI Approved :: MIT LicenseNatural Language :: EnglishOperating System :: MacOSOperating System :: Microsoft :: WindowsOperating System :: POSIX :: LinuxProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.9Topic :: File Formats :: JSON :: JSON SchemaTopic :: Utilities |
Evidence: numpydantic-1.10.0-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 array validation”
- numpydanticNumpydantic adds type annotations and validation for arrays with…
- pydantic-numpyIntegrates NumPy arrays into Pydantic models with type validation,…
- pydantic-zarrProvides Pydantic models for reading, validating, and working with…
Give your agent the search over MCP, or paste the wish link into any chat.
More Utilities 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.
Detects and normalizes text encoding from unknown or ambiguous sources, supporting all IANA character sets that Python's core library provides codecs for, with the ability to register custom codecs.
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.
Pluggy provides a plugin system that lets you define hook specifications and register implementations to be called in sequence, enabling extensible Python applications without tight coupling.
Install it if you're building an extensible application or framework.
Pygments is a syntax highlighter that colorizes source code and text in over 500 languages and formats, outputting to HTML, LaTeX, RTF, SVG, images, or ANSI terminal sequences.
Install it if you need to display or transform source code.
Six provides utility functions to write Python code that runs on both Python 2.7 and Python 3.3+, smoothing over language differences between the two versions.
See also pydantic-numpy · pydantic-zarr · nptyping · dyntastic · jaxtyping · pydantic_yaml · numpy-quaternion · pydantic-extra-types · ipydatawidgets · asdf