Skip to main content
numpy-ts supports the same file formats as NumPy: .npy (single array), .npz (multiple arrays), and delimited text files. The API is split across two entry points to keep browser bundles free of Node.js dependencies.
Node.js functions read and write files on disk. Browser functions work with ArrayBuffer, Uint8Array, and strings — you handle the network or file access yourself.

NPY files (single array)

The .npy format stores a single array with its dtype and shape metadata.
Synchronous variants are also available:

NPZ archives (multiple arrays)

The .npz format stores multiple named arrays in a single ZIP archive. savez_compressed applies deflate compression.

Text files

Load and save delimited text files such as CSV and TSV.

Flexible text loading

genfromtxt

Like loadtxt, but handles missing values more gracefully.

fromregex

Extract numeric data from unstructured text using regular expressions.

Why a separate Node.js entry point?

File I/O functions that read and write to the filesystem are in numpy-ts/node because they depend on Node.js built-in modules (fs, fs/promises). Keeping them in a separate entry point means that numpy-ts and numpy-ts/core never import fs, so they work cleanly in browsers and edge runtimes without bundler polyfills.If you only need serialization and parsing (not disk access), use serializeNpy, parseNpy, serializeNpz, parseNpz, serializeTxt, and parseTxt from the main entry points.

NumPy compatibility

Files saved by numpy-ts can be loaded by Python NumPy, and vice versa:
numpy-ts does not support NumPy object arrays, structured arrays, or pickle-based .npy files. Only numeric dtypes (float64, float32, int32, int16, int8, uint32, uint16, uint8, bool, complex128, complex64) are supported.