Shiny JSON Logic
Write your business rules in JSON, run them anywhere
The most compliant JSON Logic implementations across languages. 100% of official tests. Zero dependencies. Built by contributors to the JSON Logic specification.
Pick your language and add Shiny JSON Logic in minutes
Add shiny_json_logic to your Gemfile
(
GitHub)
:
gem 'shiny_json_logic'
Then run:
$ bundle install
require 'shiny_json_logic'
rule = { ">" => [{ "var" => "age" }, 18] }
data = { "age" => 21 }
ShinyJsonLogic.apply(rule, data)
# => true
Most JSON Logic libraries are abandoned, partially compliant, or both. Shiny is different — built by active contributors to the specification itself, tested against the official test suite, and maintained across multiple languages.
Built by maintainers and active contributors in the JSON Logic community — we help define the specification itself. We don't just copy tests, we write them.
A portable way to write business rules
The JSON Logic specification defines a standard format for expressing conditional logic as JSON. Created by Jeremy Wadhams, it enables you to write rules once and evaluate them identically across JavaScript, Ruby, Python, PHP, and many other languages.
The specification is now maintained by the json-logic community on GitHub. Shiny JSON Logic is tested against the official test suite and is the only implementation that passes 100% across multiple languages.
JSON Logic is a way to write business rules as JSON objects that can be evaluated consistently across different platforms. Instead of writing code like age >= 21, you write {">=": [{"var": "age"}, 21]}. This lets you store rules in a database, share them between frontend and backend, or let non-developers create rules through a UI.
Yes. JSON Logic is designed to be safe for untrusted input. Unlike eval(), it can only perform the operations defined in the spec—no file access, no network calls, no arbitrary code execution. You control what data the rules can access, and the operations are pure functions with no side effects.
Common use cases include feature flags (targeting rules for which users see what), access control (role-based permissions), dynamic pricing (discount eligibility), form validation (conditional field requirements), and eligibility engines (loan approvals, insurance quotes). Basically anything where business rules need to change without code deploys.
That's the whole point—but only if your implementation is spec-compliant. Many libraries have bugs that make rules behave differently than the reference JavaScript engine. Shiny passes 100% of the official JSON Logic tests in every language, so you can trust that a rule tested in the browser will work identically in your backend. That's why we built this playground to show both engines side by side.
Spec compliance AND speed: Shiny is the only family of JSON Logic libraries that passes 100% of the official tests across multiple languages (Ruby and PHP), and also the fastest in benchmark comparisons. Built by active contributors to the JSON Logic specification itself — we don't just implement the spec, we help define it.