Playground (inline)
The Full-Page Visual Editor adds visual editing, engine settings and resizable panels. This page embeds the same editor inline, with a read-only diagram, for quick checks.
Try JSONLogic expressions in your browser. This playground runs the @goplasmatic/datalogic-ui debugger on the datalogic-rs 5.9.0 engine, compiled to WebAssembly.
How to Use
- Logic: Enter your JSONLogic expression in the Logic panel
- Data: Enter the JSON data to evaluate against in the Data panel
- Result: Read the evaluated output, or the engine’s error with its type and failing operator
- Diagram: View the diagram of your logic expression and step through the evaluation with the debugger controls (Space, arrow keys, Home/End once you click the diagram)
- Examples: Use the Load Example… dropdown to load pre-built examples
- Templating: Tick the checkbox to compile multi-key objects as output templates with embedded JSONLogic
Quick Reference
Basic Operators
| Operator | Example | Description |
|---|---|---|
var | {"var": "x"} | Access variable |
== | {"==": [1, 1]} | Equality |
>, <, >=, <= | {">": [5, 3]} | Comparison |
and, or | {"and": [true, true]} | Logical |
if | {"if": [cond, then, else]} | Conditional |
+, -, *, / | {"+": [1, 2]} | Arithmetic |
Array Operations
| Operator | Example | Description |
|---|---|---|
map | {"map": [arr, expr]} | Transform elements |
filter | {"filter": [arr, cond]} | Filter elements |
reduce | {"reduce": [arr, expr, init]} | Reduce to value |
all, some, none | {"all": [arr, cond]} | Check conditions |
String Operations
| Operator | Example | Description |
|---|---|---|
cat | {"cat": ["a", "b"]} | Concatenate |
substr | {"substr": ["hello", 0, 2]} | Substring |
in | {"in": ["@", "a@b.com"]} | Contains |
Example: Feature Flag
Determine if a user has access to a premium feature:
{
"and": [
{"==": [{"var": "user.plan"}, "premium"]},
{">=": [{"var": "user.accountAge"}, 30]}
]
}
Data:
{
"user": {
"plan": "premium",
"accountAge": 45
}
}
Example: Dynamic Pricing
Calculate a discounted price based on quantity:
{
"if": [
{">=": [{"var": "quantity"}, 100]},
{"*": [{"var": "price"}, 0.8]},
{"if": [
{">=": [{"var": "quantity"}, 50]},
{"*": [{"var": "price"}, 0.9]},
{"var": "price"}
]}
]
}
Data:
{
"quantity": 75,
"price": 100
}
Learn More
- Operators Overview: Full operator documentation
- Getting Started: Using the library in your stack
- React Visual Debugger: Embed this visual editor and debugger into your own React app
- Use Cases & Examples: Real-world recipes for feature flags, pricing, and validation