Gathering detailed insights and metrics for json-logic-engine
Gathering detailed insights and metrics for json-logic-engine
Gathering detailed insights and metrics for json-logic-engine
Gathering detailed insights and metrics for json-logic-engine
ui-logic-engine
Sever JSON Driving UI
@locoworks/cijson-engine
Code in JSON
json-rules-engine-to-json-logic
A minimal Typescript library for converting a json-rules-engine condition to a JsonLogic rule specification.
@arunkumar_h/rule-engine
A lightweight and extensible rule engine built with TypeScript and Node.js. Define complex business rules and evaluate conditions easily using a simple JSON structure.
npm install json-logic-engine
Typescript
Module System
Min. Node Version
JavaScript (100%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
66 Stars
356 Commits
12 Forks
3 Watchers
4 Branches
8 Contributors
Updated on Jun 30, 2025
Latest Version
5.0.1
Package Id
json-logic-engine@5.0.1
Unpacked Size
358.97 kB
Size
65.43 kB
File Count
52
Published on
Jun 11, 2025
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
Have you ever needed the ability to write a custom set of logic or set of rules for a particular customer? Or needed to be able to configure a piece of logic on the fly?
JSON Logic might be your solution! Designed with a lisp-like syntax, JSON Logic makes it easy to write safe instructions that can be persisted into a database, and shared between the front-end and back-end.
Check out our Documentation Here.
The engine supports both synchronous & asynchronous operations, and can use function compilation to keep your logic performant at scale.
Examples:
The premise is the logic engine traverses the document you pass in, and each "object" is interpreted as an instruction for the engine to run.
1logic.run({ 2 '+': [1,2,3,4,5] 3}) // 15
If you wanted to start factoring variables, you can pass a data object into it, and reference them using the "var" instruction:
1logic.run({ 2 '+': [11, { var: 'a' }] 3}, { 4 'a': 17 5}) // 28
The engine will also allow you to reference variables that are several layers deep:
1logic.run({ 2 '+': [{ var: 'a.b.c' }, 5] 3}, { 4 a: { b: { c: 7 } } 5}) // 12
Let's explore some slightly more complex logic:
1logic.run({ 2 'reduce': [{ var: 'x' }, { '+': [{ var: 'current' }, { var: 'accumulator' }] }, 0] 3}, { 4 'x': [1,2,3,4,5] 5}) // 15
In this example, we run the reduce operation on a variable called "x", and we set up instructions to add the "current" value to the "accumulator", which we have set to 0.
Similarly, you can also do map
operations:
1logic.run({ 2 'map': [[1,2,3,4,5], { '+': [{ var: '' }, 1] }] 3}) // [2,3,4,5,6]
If var
is left as an empty string, it will assume you're referring to the whole variable that is accessible at the current layer it is looking at.
Example of a map accessing variables of the objects in the array:
1logic.run({ 2 'map': [{var : 'x'}, { '+': [{ var: 'a' }, 1] }] 3}, 4{ 5 'x': [{ a: 1 }, { a: 2 }, { a: 3 }, { a: 4 }] 6}) // [2,3,4,5]
You can easily nest different operations in each other, like so:
1logic.run({ 2 max: [200, { 3 '*': [12, {var: 'a' }] 4 }] 5}, { 6 a: 16 7}) // 200
The engine also supports Handlebars-esque style traversal of data when you use the iterative control structures.
For example:
1logic.run({ 2 'map': [{var : 'x'}, { '+': [{ var: 'a' }, { var: '../../adder'}] }] 3}, 4{ 5 'x': [{ a: 1 }, { a: 2 }, { a: 3 }, { a: 4 }], 6 'adder': 7 7}) // [8, 9, 10, 11]
This library was developed to be (for the most part) a drop-in replacement for the popular npm module json-logic-js
.
The intention of the library is to keep the functionality very similar to the original, while adding a few useful utilities.
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
6 commit(s) and 2 issue activity found in the last 90 days -- score normalized to 6
Reason
Found 0/30 approved changesets -- score normalized to 0
Reason
no SAST tool detected
Details
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
security policy file not detected
Details
Reason
18 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-07-07
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More