Back to blog

Introducing expr v1.0 — evaluate any expression in your browser

After months of iteration we're shipping v1.0 of the expression evaluator. 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 ?? "default" 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 evaluate 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 ships in v1.0

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

v1.0 highlights
Full arithmetic operator support (+ - * / % **)
Logical operators including nullish coalescing (??)
Strict equality comparison (=== !== < > <= >=)
Ternary expressions with nested support (? :)
Unary operators — negation and logical NOT
Expression history with one-click recall
REST API — evaluate from anywhere with a single GET
Full operator reference documentation

The evaluator in action

Open expr, 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 evaluated source shown below.

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

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

// Logical short-circuit
null ?? "fallback"           → "fallback"
0 || false || "last"        → "last"

// Comparison
"5" === 5                   → false
"5" == 5                    → true

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

Under the hood

The evaluator runs entirely in your browser using Function('"use strict"; return (' + expr + ')'). This is intentional — expr is a tool whose entire purpose is evaluating arbitrary JavaScript expressions. Strict mode catches a class of common mistakes (undeclared variables, duplicate parameters) while still allowing the full expression language.

Results are stored in localStorage so your history persists across sessions. No server round-trip, no account required — your expressions never leave your machine unless you explicitly use the API.

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

The REST API

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

evaluate 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

v1.0 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 for free

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

More from the blog