json-logic-js
A lightweight JavaScript engine for building, storing, and executing JsonLogic rules across the front-end, back-end, and database.
Repository Health
Technical Analysis
json-logic-js is the JavaScript implementation of JsonLogic, a shared rule format that expresses conditional logic as plain JSON so the same rule set can run identically across languages, environments, and databases. A rule is a single-key object mapping an operator to its arguments, which makes rules simple enough to author by hand, generate from a UI, store next to a database record, or send over an API — without duplicating business logic in every language that needs to evaluate it.
The library ships as a single dependency-free UMD module (logic.js) that runs unmodified in the browser, in Node via CommonJS, or through an AMD loader. It implements the full core JsonLogic operator set — comparisons, boolean logic, arithmetic, string operations, and array operations like map, filter, reduce, all, some, and none — plus data access via var, validation helpers (missing, missing_some), and utilities for introspecting rules (uses_data, rule_like) or registering custom operators at runtime.
What You Get
- A single self-contained
logic.jsUMD module with zero runtime dependencies, usable via npm, a<script>tag, or an AMD loader - A complete JsonLogic operator set out of the box: comparisons, boolean logic, arithmetic, string operations, and array operations (
map,filter,reduce,all,some,none) var,missing, andmissing_someoperators for reading and validating fields on a data object supplied at evaluation timeadd_operation/rm_operationfor registering or removing custom operators at runtime, plusrule_like/uses_datafor pattern-matching and introspecting rules before running them
Common Use Cases
- Storing user-configurable business rules (pricing, eligibility, feature flags) as JSON in a database and evaluating them at request time
- Sharing a single validation or eligibility rule set between a Node backend and a browser front-end without reimplementing the logic twice
- Building a visual rule builder UI where non-developers compose conditions that compile directly to JsonLogic
- Running the same rule against different data shapes to unit-test business logic without redeploying code
Under The Hood
Architecture
The entire library lives in one UMD-wrapped module built around a single recursive dispatcher, jsonLogic.apply(logic, data). Most operators are simple functions in a flat operations lookup table that receive their evaluated arguments and the data object as this; a handful of operators that need to control their own recursion or short-circuit (if, and, or, filter, map, reduce, all, none, some) are special-cased directly inside apply before falling through to the generic depth-first evaluation path. This keeps the control flow centralized in one function rather than split across files, so extending the language for anything beyond a plain value-in/value-out operator means editing that dispatcher directly rather than composing independent pieces — a workable design at this size, but one where every feature ultimately funnels through a single, growing conditional chain.
Tech Stack
Plain, dependency-free JavaScript targeting broad compatibility: the module uses the UMD pattern to support CommonJS (module.exports), AMD (define), and a global window.jsonLogic fallback from one file, with package.json pointing main directly at the unbundled logic.js — there is no build or bundling step in the publish path. Development tooling is limited to ESLint (Google config) for linting and QUnit for the test runner; there are no runtime dependencies and no TypeScript, so consumers get JavaScript with community-maintained type definitions rather than first-party types.
Code Quality
Testing is thorough for the library’s scope: the QUnit suite in tests/tests.js downloads a shared, cross-language conformance test set (tests.json, rule_like.json) from jsonlogic.com — the same fixtures used to validate JsonLogic ports in other languages — and layers on hand-written edge-case tests for falsy data, custom operator registration, and error paths. Error handling is explicit: unrecognized operators throw a descriptive Error rather than failing silently. No CI workflow configuration is present in the repository, and there is no static type system, so correctness relies on the conformance suite plus ESLint rather than compiler-enforced guarantees.
API Design
The public surface is intentionally tiny: one entry point, jsonLogic.apply(rule, data), evaluates any rule against any data object, with syntactic sugar that lets unary operators skip the surrounding array ({"var": "a"} instead of {"var": ["a"]}). Getting started requires no setup beyond importing the module and calling apply — there’s no configuration object, no class to instantiate, and no boilerplate. add_operation extends the language with the same low ceremony, and the operator vocabulary mirrors the shared JsonLogic spec documented (with a live playground) at jsonlogic.com, which lowers the learning curve for anyone who has seen JsonLogic in another language.
Used by 6 apps in this directory
Chatwoot
Customer Support
Open-source omnichannel customer support platform with AI-powered agents, live chat, and self-hosting — a full Intercom and Zendesk alternative.
Novu
Developer Tools
Open-source communication infrastructure that connects your products and AI agents to every channel your users live on — Inbox, Email, SMS, Push, Chat, and more.
Plasmic
CMS · Low Code Platforms · No Code Platforms
The open-source visual builder that lets teams design React apps and websites with drag-and-drop while integrating seamlessly with your codebase.
strapi
CMS
Open-source headless CMS that auto-generates REST and GraphQL APIs from your content models, with a fully customizable admin panel you control.
Supabase
Developer Tools · Databases · Search
The open-source Postgres development platform that replaces Firebase with authentication, real-time APIs, edge functions, storage, and vector embeddings — all built on PostgreSQL.
twenty
CRM
The open-source CRM you build, ship, and version like the rest of your stack — with customizable objects, AI agents, and a TypeScript SDK.