mathjs

Extensive math library for JavaScript and Node.js with big numbers, complex numbers, units, and matrices.

Library
npm
v15.2.0
15,063stars
Apache License 2.0

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
66/100Good
Development Activity64
Maintenance24
Community76
Maturity60
Momentum40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
84/100Excellent
Architecture88
Code Quality85
Innovation82
Learning Curve80

Math.js is a comprehensive math library for JavaScript and Node.js that goes far beyond the built-in Math object. It supports numbers, BigNumbers, bigints, complex numbers, fractions, units, strings, arrays, and matrices, all interoperable through a typed-function and dependency-injection architecture that lets custom data types plug into existing operators. On top of the numeric core it ships a flexible expression parser capable of symbolic computation and chained operations, so consumers can evaluate string expressions like unit conversions or determinants directly.

Because every function is generated from small, composable factory functions, applications can import the full library or hand-pick a lightweight subset (e.g. plain-number-only variants) to control bundle size. It runs identically in Node.js and any ES2020-compatible browser, and includes a CLI for quick expression evaluation from the terminal.

What You Get

  • A drop-in superset of JavaScript’s Math library with extensive numeric type support (BigNumber, bigint, Complex, Fraction, Unit, Matrix)
  • A string expression parser supporting symbolic computation, unit conversions, and chained operations
  • Extensible typed functions and dependency injection so new data types integrate with existing operators
  • Tree-shakeable factory functions for building lightweight, number-only bundles
  • A command-line interface for evaluating expressions without writing JavaScript
  • TypeScript type definitions maintained alongside the JavaScript source

Common Use Cases

  • Scientific and engineering calculators that need big numbers, complex numbers, or unit-aware arithmetic
  • Spreadsheet-like applications evaluating user-entered formulas via the expression parser
  • Symbolic computation such as computing derivatives of algebraic expressions
  • Matrix and linear algebra operations in data-processing or visualization tools
  • Unit conversion utilities embedded in web or Node.js applications

Under The Hood

Architecture - Mathjs is built around two ideas: typed functions (via the companion typed-function library) that dispatch operators like multiply across numbers, BigNumbers, complex numbers, fractions, and units, and dependency injection, where higher-level functions such as prod are generated by wiring together the specific lower-level function implementations they need (e.g. a lightweight number-only multiply versus the full multi-type version). math.create() builds a mathjs instance from a chosen set of factory functions in src/factoriesAny.js or src/factoriesNumber.js, and math.import() lets consumers extend an instance with new functions at runtime, which is also how the expression parser gains access to user-defined functions.

Tech Stack - The library is written in ES modules (plain .js with .js extensions, no bundler-only syntax) and is 98% JavaScript with a small TypeScript definitions layer under types/. It depends on focused single-purpose packages for each numeric type: decimal.js for BigNumbers, complex.js for complex numbers, fraction.js for rational numbers, plus typed-function for the dispatch system and seedrandom/tiny-emitter for supporting utilities. Babel and a custom gulpfile-driven build produce ESM, CommonJS, and browser-bundle outputs into lib/.

Code Quality - The test/unit-tests tree mirrors src/function category-by-category (arithmetic, matrix, probability, etc.), and there are separate suites for TypeScript type definitions (test/typescript-tests), generated tree-shaken entry points (test/generated-code-tests), and Node-specific CLI behavior (test/node-tests). Contribution docs require every new function to include History-tagged source documentation, embedded docs for the website, unit tests, and TypeScript definitions added in multiple places, indicating a disciplined, checklist-driven contribution process backed by ESLint/Prettier via npm run lint/format.

API Design - The top-level API mirrors the built-in Math object for familiarity (round, sqrt, pow), while evaluate() and chain() provide two additional ergonomic entry points for string-based expressions and fluent method chaining respectively. Getting started requires a single npm install mathjs and one import statement, with no configuration; the tradeoff is a large default bundle unless consumers opt into the tree-shakeable factory-function API, which requires more advanced knowledge of the dependency graph.

Used by 14 apps in this directory

Other

Akaunting

Invoicing Finance

10,070

Open-source online accounting for small businesses and freelancers — invoices, expenses, and reporting without monthly fees or vendor lock-in.

View details
98
Repo Health
73
Technical
63
Dependency
Updated yesterday
TypeScript
97%
AGPL 3.0

Bigcapital

Invoicing Finance

3,846

Self-hostable double-entry accounting platform with invoicing, inventory, multi-currency, and real-time financial reporting for small and medium businesses.

View details
91
Repo Health
77
Technical
64
Dependency
Built with
TypeScript97%
Updated yesterday
Java
78%
GPL 3.0

DataEase

Analytics · Data Engineering · AI Assistants

24,346

Open-source BI tool with drag-and-drop dashboards, 20+ data source connectors, and AI-powered natural language queries — a self-hosted alternative to Tableau.

View details
94
Repo Health
71
Technical
66
Dependency
Built with
Java78%
Vue22%
Updated today
Vue
50%
GPL 3.0

IT-Tools

Developer Tools

40,279

A unified collection of 88 web-based developer utilities — from JSON formatting to subnet calculation — all self-hostable, keyboard-searchable, and offline-ready.

View details
60
Repo Health
74
Technical
67
Dependency
Built with
Vue50%
TypeScript48%
Updated 3 days ago
TypeScript
80%
MIT

LibreChat

Developer Tools · AI Assistants

42,216

Unite every major AI model in one self-hosted chat platform with agents, code execution, MCP tools, and enterprise authentication.

View details
93
Repo Health
81
Technical
68
Dependency
Built with
TypeScript80%
JavaScript19%
Updated today
TypeScript
99%
Other

LobeHub

AI Assistants · Productivity · Automation

81,816

Your Chief Agent Operator — build, schedule, and collaborate with an entire AI team in one self-hostable workspace.

View details
92
Repo Health
81
Technical
72
Dependency
Built with
TypeScript99%
Updated today
JavaScript
57%
Other

Lokus

Note Taking · Knowledge Management

774

Local-first note-taking with graph view, canvas & AI plugins—your Markdown files, zero telemetry, blazing-fast Rust performance.

View details
78
Repo Health
75
Technical
65
Dependency
Built with
JavaScript57%
HTML24%
Updated 1 weeks ago
TypeScript
76%
AGPL 3.0

massCode

Developer Tools · Productivity · Code Editors

6,959

A free, local-first developer workspace unifying snippets, notes, HTTP requests, calculations, drawings, and dev tools in one desktop app.

View details
86
Repo Health
87
Technical
64
Dependency
Built with
TypeScript76%
Vue22%
Updated 2 days ago
PHP
79%
GPL 3.0

matomo

Analytics

21,786

Open-source, privacy-first web and app analytics that puts you in complete control of your data.

View details
95
Repo Health
82
Technical
62
Dependency
Built with
PHP79%
Updated today

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search