stdlib: A Numerical Standard Library for JavaScript and TypeScript
The fundamental numerical library for JavaScript and TypeScript. stdlib ([/ˈstændərd lɪb/][ipa-english] "standard lib") is a standard library with an emphasis on numerical and scientific computation, written in JavaScript (and C) for execution in browsers and in Node.js.
At a glance
- What is it?
- stdlib is a decomposable standard library for numerical and scientific computing in JavaScript and TypeScript, with 150+ math functions, 35+ distributions, and 40+ PRNGs. It targets browsers and Node.js, but its breadth and modularity come with trade-offs in installation and learning.
- Who is it for?
- Adopt stdlib if you need rigorous, well-documented numerical functions in JavaScript or TypeScript, especially in Node.js or browser bundles where modular installation keeps size down. Avoid it if you prefer a monolithic import or need a small dependency footprint without granular setup.
- Can I use it commercially?
- Yes. Apache-2.0 is a permissive licence: you can use, modify and sell software built on it, as long as you keep its copyright and licence notices.
- Is it still maintained?
- Yes. The repository received new commits within the last day.
- What is it written in?
- Mainly JavaScript, according to GitHub's language statistics.
Answers come from the project's GitHub data, last synced on September 15, 2026, and from our analysis. They are not legal advice.
DEEP OPEN-SOURCE ANALYSIS
The Problem: JavaScript's Missing Numerical Foundation
JavaScript has no built-in standard library for mathematics, statistics, or data processing. Developers reaching for Python, Julia, R, or MATLAB find themselves writing custom implementations or gluing together scattered packages. stdlib addresses this by providing a cohesive collection of numerical and scientific tools, written in JavaScript and C, for browsers and Node.js. It is for data scientists doing analysis in Node.js, web developers needing math functions in the browser, and anyone who wants a standard library with the rigor of a scientific computing environment. The README states its goal: 'a future in which the web is a preferred environment for numerical computation.' That is a specific ambition, and the library's design reflects it.
Decomposable Architecture: Mix and Match Packages
The core design choice is full decomposability. Instead of one monolithic package, stdlib is split into individual packages, each addressable under scopes like @stdlib/math/base/special. The README says this allows you to 'swap out and mix and match APIs and functionality to cater to your exact preferences and use cases.' In practice, this means you can install only the functions you need, which keeps bundle size down for web applications. It also means the library is not a single npm install; you pick and choose. That is a strength for tree-shaking and customization, but it adds friction: you must know which package contains which function. The trade-off is explicit in the documentation, which warns that installing the entire project is 'likely unnecessary and will lead to slower installation times.'
What You Get: Math, Stats, Random, and More
The feature list is broad. There are 150+ special math functions, 35+ probability distributions with PDFs, CDFs, quantiles, and moments, and 40+ seedable pseudorandom number generators. Beyond that, there are 200+ utilities for data transformation and functional programming, 200+ assertion utilities for validation, and 50+ sample datasets for testing. A plot API exists for visualization, and a benchmark framework supports TAP. Native add-ons interface with BLAS libraries, with pure JavaScript fallbacks. Every function ships with TypeScript declaration files. This is not a toy library. The breadth suggests a serious attempt to replicate the scope of a scientific computing standard library. The README claims 'thorough, rigorous, well-written, studied, documented, tested, measured, and high-quality code,' which is a bold promise; the actual quality depends on the individual package.
Installation Paths: From CLI to Custom Bundles
The README details multiple installation methods based on use case. For data analysis in Node.js, you can install the entire project as a command-line utility. For web applications, the recommended path is to install individual packages, which avoids slow installation times. You can also create custom bundles to vendor specific functionality, or use ES Module builds for individual packages. For quick inclusion, pre-built UMD browser bundles are available via CDNs like unpkg or jsDelivr. The default is npm, but swapping to yarn is a matter of changing commands. This flexibility is useful, but it means there is no single 'npm install stdlib' that gives you everything. You must decide your path upfront. The README's user stories guide that decision, but they assume you know whether you are building an app or doing analysis.
Native Add-ons and the BLAS Interface
A notable feature is native add-ons for interfacing with BLAS libraries, which are standard building blocks for linear algebra. The README mentions these add-ons come with pure JavaScript fallbacks. This is a pragmatic approach: you get performance when native modules are available, but you still have a working implementation in pure JavaScript. The fallback is critical for browser environments where native add-ons cannot run. However, the documentation does not specify which BLAS libraries are supported or how to configure the fallback. That gap matters for production use. If you rely on native performance, you need to verify that your environment supports the add-on build. The fallback likely works, but the README does not detail its performance characteristics. This is a limitation to check before adopting.
Limitations and When to Look Elsewhere
The biggest limitation is the learning curve. With hundreds of packages, finding the right function is not trivial. The README mentions a REPL with integrated help, but that does not solve discovery in a code editor. Another limitation is the install complexity. The README warns against installing the entire project for web apps, but that warning is easy to miss. If you install everything, you get slow installs and a bloated bundle. Also, the library is not a drop-in replacement for a language like Python. It does not include a full numerical computing environment like NumPy or SciPy; it provides building blocks. For tasks like linear algebra, you might need to combine stdlib with other libraries. The documentation does not claim to replace those, but users coming from Python might expect that. Finally, the project is under active development, with v0.4.1 released in June 2026, so APIs may change between versions.
Alternatives: How stdlib Differs
A common alternative is using a general-purpose utility library like Lodash, which includes some math functions but lacks scientific depth. Lodash is not designed for numerical computation; it has no probability distributions or BLAS interfaces. Another alternative is to use a dedicated math library like Math.js. Math.js provides a larger set of mathematical functions and expression parsing, but it is a single monolithic package. stdlib's decomposable architecture is the key difference: you can install only the functions you need, which is not possible with Math.js. For TypeScript users, stdlib's built-in declarations are a plus, but Math.js also has types. The choice depends on whether you value granular control (stdlib) or a one-stop import (Math.js). For heavy numerical work, you might also consider WebAssembly-based libraries, but stdlib's pure JavaScript fallbacks keep it portable.
Maintenance and License Considerations
The repository is not archived, and the last push was June 6, 2026, with a v0.4.1 release on the same day. That indicates active maintenance. The license is Apache-2.0, which is permissive and allows commercial use, modification, and distribution, with conditions around patent grants and attribution. That is a favorable license for most projects. The README references a development guide, suggesting a structured contribution process. Upgrade cost depends on how you use the library. If you install individual packages, updating each one is a separate step. The decomposable architecture means you might have many dependencies, each needing version bumps. The project's public API is versioned, but the rapid release schedule (v0.4.0 and v0.4.1 on the same day) suggests changes are frequent. Plan for regular updates and check release notes for breaking changes.
Editorial conclusion
Adopt stdlib if you need rigorous, well-documented numerical functions in JavaScript or TypeScript, especially in Node.js or browser bundles where modular installation keeps size down. Avoid it if you prefer a monolithic import or need a small dependency footprint without granular setup. Before adopting, verify that the specific functions you need are available in the current release, check the TypeScript declarations for your version, and test the pure JavaScript fallbacks if you cannot use native BLAS add-ons. The project's active development (v0.4.1 in June 2026) suggests ongoing maintenance, but confirm your target environment's compatibility with the package's build system.
Community notes