Skip to main content
Hero Light

Complete NumPy for TypeScript

The most comprehensive NumPy implementation for TypeScript and JavaScript. Write numerical computing code with the same API you already know from Python — fully type-safe, tree-shakeable, and validated against NumPy itself.
npm install numpy-ts

Why numpy-ts?

94% API Coverage

476 of 507 NumPy functions implemented. From basic arithmetic to FFT, linear algebra, random distributions, and beyond.

Faster than NumPy

1.13x faster than NumPy on average across 7,200 benchmarks. Faster in 12 of 18 categories, across all array sizes and dtypes.

Zero Dependencies

No native modules, no third-party packages. Pure TypeScript + WASM that runs everywhere JavaScript runs.

NumPy-Validated

Over 20,000 tests compare outputs directly against NumPy. If NumPy produces a result, numpy-ts matches it.

Type-Safe

Full TypeScript type definitions for every function, dtype, and array operation. Catch errors at compile time, not runtime.

Tree-Shakeable

Import only what you need. Bundlers eliminate unused code automatically, keeping your production builds small.

Quick Example

import * as np from 'numpy-ts';

// Create arrays -- just like NumPy
const a = np.array([[1, 2], [3, 4]]);
const b = np.zeros([2, 2]);

// Broadcasting works as expected
const c = a.add(1);        // [[2, 3], [4, 5]]
const d = a.multiply(2);   // [[2, 4], [6, 8]]

// Linear algebra
const inv = np.linalg.inv(a);
const det = np.linalg.det(a); // -2

// Dot products and matrix multiplication
const e = np.dot(a, np.array([[5, 6], [7, 8]]));  // [[19, 22], [43, 50]]

// Reshape, slice, and manipulate
const r = np.arange(12);
const grid = np.reshape(r, [3, 4]);

Get Started

Quickstart

Install numpy-ts and write your first array operations in under 5 minutes.

API Reference

Browse all 476 implemented functions with signatures, parameters, and examples.

Examples

Real-world examples covering linear algebra, signal processing, statistics, and more.

Benchmarks

Detailed performance comparisons against NumPy across 18 categories, multiple dtypes, and array sizes.

Coming from NumPy?

numpy-ts mirrors the NumPy API as closely as possible. Most code translates directly:
import numpy as np

a = np.array([[1, 2], [3, 4]])
b = np.linalg.inv(a)
c = np.dot(a, b)          # identity matrix
d = np.sum(a, axis=0)     # [4, 6]
e = a[0, :]               # [1, 2]
See the NumPy Migration Guide for a complete translation reference.