Math.js API
Free maths API with no key: send an expression as a query parameter and get the evaluated result back as plain text. Handles units, matrices and functions. Tested example included.
Endpoint tested and returned HTTP 200 on 2026-08-21
What is the Math.js API?
The Math.js API evaluates mathematical expressions sent as a query parameter, with no API key. It returns the result directly in the response body, and understands arithmetic, functions, units, complex numbers and matrices.
This is the hosted form of Math.js, the JavaScript expression parser, and its usefulness is that the expression syntax goes far beyond arithmetic. It handles unit-aware calculations — `2 inch to cm` returns a converted value with the unit attached — as well as matrices, complex numbers, symbolic derivatives and a large function library, all through the same single parameter.
The response is the bare result, not a JSON envelope: asking for `2*(3+4)` returns the two characters `14`. That makes it trivially easy to consume, though the declared content type is `text/html` rather than anything more accurate. For anything beyond a quick lookup, the POST form is the one to use — it accepts a JSON body with an array of expressions and returns an array of results, avoiding the URL-encoding gymnastics that operators like `+` otherwise demand. The service is offered for occasional use and explicitly asks that you self-host if you need volume.
Quick facts
- Base URL
https://api.mathjs.org/v4- Authentication
- No API key and no account. The operator asks that heavy users run their own instance rather than relying on the public one.
- Rate limit
- Fair use, unpublished. Intended for occasional queries, not production traffic.
- Pricing
- Free. Math.js is open source and self-hostable.
- CORS
- Enabled — callable directly from browser JavaScript
- Official docs
- Read the docs
How to use the Math.js API
Every request below was executed against the live API on 2026-08-21, and the response shown is the real body it returned — not an illustration.
1. Evaluate a mathematical expression
GET https://api.mathjs.org/v4/?expr=2*(3%2B4)
curl 'https://api.mathjs.org/v4/?expr=2*(3%2B4)'const res = await fetch("https://api.mathjs.org/v4/?expr=2*(3%2B4)");
if (!res.ok) throw new Error(`Request failed: ${res.status}`);
const data = await res.json();
console.log(data);import requests
res = requests.get("https://api.mathjs.org/v4/?expr=2*(3%2B4)", timeout=20)
res.raise_for_status()
print(res.json())14Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
expr | query | Required | The expression to evaluate, URL-encoded. `+` must be encoded as `%2B` or it is read as a space. 2*(3%2B4) |
precision | query | Optional | Significant digits in the result. 6 |
(POST body) | body | Optional | A JSON object with an `expr` array evaluates several expressions in one request and returns an array of results. |
Response fields
(body)text- The evaluated result as bare text — `14` for the captured example. There is no JSON envelope.
Content-Typeheader- Declared as `text/html` despite the body being a plain value. Do not rely on the header to decide how to parse.
(POST response)object- The POST form returns a JSON object with a `result` array and an `error` field, unlike the GET form.
What you can build with the Math.js API
- Add expression evaluation to a chat bot or command palette
- Perform unit-aware conversions without bundling a maths library
- Validate a formula from user input server-side
- Evaluate a batch of expressions in one request via POST
Common errors and how to fix them
Result is wrong by an addition
An unencoded `+` in a query string decodes as a space.
Fix: Encode it as `%2B`. This is the single most common mistake with the GET form.
Error message instead of a number
Math.js returns its parse error as the response body.
Fix: The body carries a readable message. Check whether the response parses as a number before using it.
Rate limited
The public instance is offered for occasional use.
Fix: Self-host Math.js if you need volume. The library is open source and the API is a thin wrapper.
Long expressions rejected
URL length limits apply to the GET form.
Fix: Use the POST form with a JSON body, which also avoids all the encoding problems.
Math.js API — frequently asked questions
Is the Math.js API free?
Yes, free with no key. It is offered for occasional use, and the operator asks anyone needing volume to self-host the open source library instead.
Why does my calculation with a plus sign give the wrong answer?
Because an unencoded `+` in a query string means a space. Encode it as `%2B`, or use the POST form where the problem does not arise.
What can the expressions do?
Far more than arithmetic — unit conversion such as `2 inch to cm`, matrices, complex numbers, symbolic derivatives and a large built-in function library, all through the same parameter.
Can I evaluate several expressions at once?
Yes, with the POST form. Send a JSON body containing an `expr` array and you get an array of results back, along with an `error` field.
Tools that pair with this API
Scientific Calculator
Free online scientific calculator with sin, cos, tan in degrees or radians, log, ln, powers, roots, π, e, parentheses, memory keys and keyboard support.
Unit Converter
Convert between units of length, weight, temperature, area, volume, speed, time and data storage instantly, with a swap button and common conversion tables.
Big Number Calculator
Add, subtract, multiply, divide and raise huge integers to powers with exact arbitrary-precision arithmetic — hundreds or thousands of digits, no rounding.
Math.js API is an independent third-party service and is not affiliated with ByteTools or ByteVancer. Details on this page were verified on 2026-08-21; always check the official documentation before relying on this API in production, as terms and limits can change.