Compare · Expressions and rules
Stof vs JsonLogic.
JsonLogic delegates one decision as JSON, with no functions or loops. Stof is JSON that holds whole programs: functions, types, and tests, sandboxed.
JsonLogic
Rules written as JSON objects, shared between front end and back end.
Stof
Just-in-time software: data and logic together, in one document that runs anywhere, sandboxed, in Rust, JavaScript, and Python.
What happens when…
When…JsonLogicStof
A model writes the logicSafe, because rules can only use the operators your app provides.Parse it as untrusted (nothing runs while it parses), seal it to what you list, and call it. Or describe the function as an intent, and a model writes it, checked by your examples.
The logic outgrows one decisionNo setters, loops, or functions in a rule. New behavior is an operator added in each host.Write functions and helpers in the doc. Your app adds functions only for what it wants to hand over.
The logic has to run somewhere elseIts strength: a rule is plain JSON, easy to store and send. The data goes separately, and custom operators have to exist on each side.Send the doc as text or compact binary: its data, its functions, and its current state, in one payload. The other side gives the same answer, in Rust, JavaScript, or Python.
Reading the rulesA tree of JSON operators, like {"and": [{"<": [{"var": "temp"}, 110]}, ...]}.Code that reads like JSON and JavaScript, next to the data it works on.
Your app is TypeScript, Python, or RustParsers in JavaScript, Python, Go, Java, .NET, PHP, Ruby, and C++, each adding operators its own way.One runtime, with packages for Rust, JavaScript and TypeScript (WebAssembly), and Python. The same doc runs in each.
What you send to move the workSmall too: one rule as JSON. Its data goes separately, and each side needs the same operators.The text itself: fn hello() { pln('hello world'); } is 34 bytes. A doc brings its data and state the same way, and server B, with the Stof package, runs it the same as server A.
Checked December 3, 2026. Sources: jsonlogic.com · JsonLogic operations. Something out of date? Tell us.
What you'd still build.
On top of JsonLogic
- Custom operators, in every language you run
- Anything past one decision
- Tests for the rules
Already in Stof
- The same doc in Rust, JavaScript, and Python
- Functions, types, units, and tests in the same doc
- Tests (#[test]) in the doc
Choose JsonLogic for one small decision stored as data, where the rule really is one line.
Stof vs JsonLogic, answered.
Both are JSON. What's different?
JsonLogic is a rule format inside JSON. Stof is a superset of JSON: any JSON is a Stof document, and it can hold functions, types, and tests next to the data.
Also compared.
Try it in a minute.
npm i @formata/stof
pip install stof
cargo add stof