JSONLogic Shiny JSON Logic

JSONLogic JSONLogic done right

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.

Ruby 601/601 PHP 601/601 Crystal coming soon
Rule (JSON Logic) logic
Data (JSON) input
Ruby shiny_json_logic
Hit Evaluate to see the result
JavaScript json-logic-engine
Hit Evaluate to see the result

Get Started

Pick your language and add Shiny JSON Logic in minutes

1

Install

Add shiny_json_logic to your Gemfile ( GitHub) :

Gemfile
gem 'shiny_json_logic'

Then run:

Terminal
$ bundle install
2

Use

app.rb
require 'shiny_json_logic'

rule = { ">" => [{ "var" => "age" }, 18] }
data = { "age" => 21 }

ShinyJsonLogic.apply(rule, data)
# => true

Why Shiny JSON Logic?

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.

The JSON Logic Specification

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.

Frequently Asked Questions

What is JSON Logic?

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.

Is JSON Logic safe to evaluate user input?

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.

What can I build with JSON Logic?

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.

Does JSON Logic work the same across languages?

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.

Why choose Shiny JSON Logic over other libraries?

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.