> ## Documentation Index
> Fetch the complete documentation index at: https://numpyts.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# numpy-ts

![Hero Light](https://mintcdn.com/none-4568e96a/TklIwzPdQ8Sv_cxD/images/hero-light.svg?fit=max\&auto=format\&n=TklIwzPdQ8Sv_cxD\&q=85\&s=a87369e10ad3e6312d8feb804407459e)

# 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.

> [tab] npm
>
> ```bash theme={null}
> npm install numpy-ts
> ```

> [tab] yarn
>
> ```bash theme={null}
> yarn add numpy-ts
> ```

> [tab] pnpm
>
> ```bash theme={null}
> pnpm add numpy-ts
> ```

> [tab] bun
>
> ```bash theme={null}
> bun add numpy-ts
> ```

> [tab] deno
>
> ```bash theme={null}
> deno add npm:numpy-ts
> ```

## Why numpy-ts?

> [card] 94% API Coverage
>
> 476 of 507 NumPy functions implemented. From basic arithmetic to FFT, linear algebra, random distributions, and beyond.

> [card] Faster than NumPy
>
> 1.22x faster than NumPy on average across 11,200 benchmarks. Faster in 13 of 18 categories and at every array size.

> [card] Zero Dependencies
>
> No native modules, no third-party packages. Pure TypeScript + WASM that runs everywhere JavaScript runs.

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

> [card] Type-Safe
>
> Full TypeScript type definitions for every function, dtype, and array operation. Catch errors at compile time, not runtime.

> [card] Tree-Shakeable
>
> Import only what you need. Bundlers eliminate unused code automatically, keeping your production builds small.

## Quick Example

```typescript theme={null}
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

> [card] [Quickstart](https://numpyts.dev/quickstart.md)
>
> Install numpy-ts and write your first array operations in under 5 minutes.

> [card] [API Reference](https://numpyts.dev/api.md)
>
> Browse all 476 implemented functions with signatures, parameters, and examples.

> [card] [Examples](https://numpyts.dev/examples.md)
>
> Real-world examples covering linear algebra, signal processing, statistics, and more.

> [card] [Benchmarks](https://numpyts.dev/performance.md)
>
> 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:

> [tab] Python (NumPy)
>
> ```python theme={null}
> 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]
> ```

> [tab] TypeScript (numpy-ts)
>
> ```typescript theme={null}
> import * as np from 'numpy-ts';
>
> const a = np.array([[1, 2], [3, 4]]);
> const b = np.linalg.inv(a);
> const c = np.dot(a, b);          // identity matrix
> const d = np.sum(a, 0);          // [4, 6]
> const e = a.slice('0', ':');     // [1, 2]
> ```

See the [NumPy Migration Guide](https://numpyts.dev/migration.md) for a complete translation reference.

***

numpy-ts is brought to you by

[![Cyborg](https://mintcdn.com/none-4568e96a/LOd94mpG5ESu-HdJ/images/sponsors/cyborg-light.svg?fit=max\&auto=format\&n=LOd94mpG5ESu-HdJ\&q=85\&s=112d39bfc43ad0b747f79528e623d57e)](https://www.cyborg.co/?utm_source=numpy-ts\&utm_medium=docs-home)

Built by [Nico Dupont](https://nico.codes)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.