Yexp — an expression language for JSON

An expression language for JSON.
Compile once. Evaluate against any input.

Read the documentation ↗
Run your own expression ↗
INSIDE THE ENGINE

From expression to result.

Compile once. Run the same instructions against your data.

01 Expression & data
$.price * $.quantity
INPUT AT $
{
  "price": 50,
  "quantity": 3
}
02 Compiled instructions
00LOAD $.price
01LOAD $.quantity
02MUL
03RETURN
Ready to inspect · 4 instructions
03 Result
15050 × 3NUMBER
Inspect parsing
Binary · *
$.price$.quantity
Explore the virtual machine ↗
TypeScript & JavaScriptZero runtime dependenciesMIT licensedApplication + CLI
01 / THE LANGUAGE

Less ceremony.
More meaning.

JavaScript-shaped expressions, with a few thoughtful additions for the way you actually work with data.

Explore the language ↗
01

Find your way through JSON.

Nested properties, optional chaining, and a fallback when data is missing.

$.user.profile.name ?? "Anonymous"
02

Keep only what matters.

Filter a collection in place. Project exactly the fields you need.

$.products[.price < 100][*].name
03

Let one step feed the next.

Compose a transformation with pipes and familiar arrow functions.

$.users |> filter(.active) |> map(.name)
02 / THE RUNTIME

Write it once.
Run it again.

Compile an expression into a portable program. Cache it, serialize it, or evaluate it against the next input.

The VM runs bytecode with explicit data roots: $, $context, and $env. Your application decides what else it can access.

Meet the virtual machine ↗
app.tsTYPESCRIPT
import { compile, evaluate } from '@cristianmartinez/yexp';

// An expression becomes a reusable program.
const total = compile('$.price * $.quantity');

// Same bytecode. Different input.
evaluate(total, { price: 50, quantity: 3 }); // 150
evaluate(total, { price: 25, quantity: 2 }); // 50
↳ No generated JavaScript. No ambient globals.
03 / THE TERMINAL

A small tool.
In your toolchain.

JSON in. An expression. A result out.
The same language, right in your shell.

Get the CLI ↗
~/your-project — zsh
$ echo '{"name":"Ada"}' | \
  npx @cristianmartinez/yexp-cli '.name'
"Ada"↳ stdout
OPEN SOURCE. READY TO EMBED.

Put your data
into words.

Open the playground ↗