json-logic-js

A lightweight JavaScript engine for building, storing, and executing JsonLogic rules across the front-end, back-end, and database.

Library
npm
v2.0.5
1,480stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
44/100Fair
Development Activity0
Maintenance20
Community56
Maturity60
Momentum40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
63/100Good
Architecture58
Code Quality62
Innovation75
Learning Curve55

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.js UMD 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, and missing_some operators for reading and validating fields on a data object supplied at evaluation time
  • add_operation/rm_operation for registering or removing custom operators at runtime, plus rule_like/uses_data for 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

Ruby
49%
Other

Chatwoot

Customer Support

36,549

Open-source omnichannel customer support platform with AI-powered agents, live chat, and self-hosting — a full Intercom and Zendesk alternative.

View details
95
Repo Health
78
Technical
69
Dependency
Built with
Ruby49%
Vue26%
JavaScript22%
Updated yesterday
TypeScript
98%
Other

Novu

Developer Tools

39,870

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.

View details
93
Repo Health
80
Technical
64
Dependency
Built with
TypeScript98%
Updated yesterday
TypeScript
88%
MIT

Plasmic

CMS · Low Code Platforms · No Code Platforms

6,993

The open-source visual builder that lets teams design React apps and websites with drag-and-drop while integrating seamlessly with your codebase.

View details
81
Repo Health
78
Technical
64
Dependency
Built with
TypeScript88%
Updated yesterday
TypeScript
88%
Other

strapi

CMS

73,083

Open-source headless CMS that auto-generates REST and GraphQL APIs from your content models, with a fully customizable admin panel you control.

View details
93
Repo Health
84
Technical
66
Dependency
Built with
TypeScript88%
JavaScript12%
Updated yesterday
TypeScript
71%
Apache 2.0

Supabase

Developer Tools · Databases · Search

108,912

The open-source Postgres development platform that replaces Firebase with authentication, real-time APIs, edge functions, storage, and vector embeddings — all built on PostgreSQL.

View details
90
Repo Health
91
Technical
62
Dependency
Built with
TypeScript71%
MDX26%
Updated today
TypeScript
80%
Other

twenty

CRM

56,361

The open-source CRM you build, ship, and version like the rest of your stack — with customizable objects, AI agents, and a TypeScript SDK.

View details
92
Repo Health
82
Technical
64
Dependency
Built with
TypeScript80%
MDX17%
Updated yesterday

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search