Back to blog

Introducing Expression Calculator — calculate any expression in your browser

After months of iteration we're shipping expression calculator. It handles arithmetic, logical, comparison, and ternary expressions out of the box — all without a build step.

Why we built this

Every developer has been there: you need to quickly verify what null == null returns, or whether 0 || false || "fallback" short-circuits correctly. The options are either opening DevTools, spinning up a REPL, or mentally simulating the JavaScript spec. None of those are fast.

expr started as an internal scratch tool — a single input box that ran Function('"use strict"; return (' + expr + ')') and printed the result. It was five lines of JavaScript. We added history. Then syntax highlighting on the result. Then an API so you could calculate expressions from curl. At some point it became a real product.

The best developer tools feel like they were always there — you just needed someone to make them obvious.

What is included in version 1.0?

This release is the foundation. Everything you need to calculate, understand, and integrate JavaScript expressions, with no configuration and no installation required.

v1.0 highlights
Full arithmetic operator support (+ - * / %)
Logical operators LOGICAL AND, LOGICAL OR and many more.
equality comparison (== != < > <= >=)
Ternary expressions with nested support (? :)
Unary operators — unary minus (negation), unary plus and logical NOT
Expression history with one-click recall (session based)
REST API — calculate from anywhere with a single POST request
Full operator reference documentation

The Expression Calculator in action

Open expression calculator, type an expression, and press Enter. That's the whole interface. No accounts, no configuration, no JavaScript to import. The result appears instantly — success states in green, errors in red, with the calculated source shown below.

Here are a few expressions worth trying on your first run:

expressions to try
// Arithmetic
2 * 10                     → 20
17 % 5                      → 2

// Logical short-circuit
true || false || true        → true

// Comparison
"5" == "5"                   → true
"5" == 5                    → error, Unsupported operation == for Number and String.

// Ternary
42 > 10 ? "big" : "small"   → "big"

Under the hood

Expression calculator is a tool whose entire purpose is evaluating all kinds of expressions. It catches a class of common mistakes like undeclared variables, while still allowing the full expression language.

Results are not stored on server or localStorage, but your history persists during sessions. No server round-trip, no account required — your expressions never leave your browser.

<1ms Local evaluation
<30ms API p99 latency
0 Dependencies
13 Operators supported

The REST API

For server-side and CI use cases, expression calculator ships a REST API via RapidApi that accepts any expression and returns a structured JSON response. Authentication uses API key passed in the Authorization header.

calculate via curl
# Simple GET request
curl "https://api.expr.dev/v1/evaluate?expr=2**10" \
  -H "Authorization: Bearer YOUR_KEY"

# Response
{
  "ok":     true,
  "result": 1024,
  "type":   "number",
  "expr":   "2**10"
}

Error responses follow the same schema — ok: false with a human-readable error field and an errorType for programmatic handling. See the operator reference for the full list of evaluable expressions and their expected return types.

What's next

Initial version covers the core expression set. Here's what's on the roadmap for v1.1 and beyond:

If there's something you'd like to see, let us know. The roadmap is shaped almost entirely by what developers actually need.

Try expr here

No account needed. Open the evaluator, type an expression, and see the result instantly.

More from the blog