json-logic
Build complex rules, serialize them as JSON, and execute them in Python
What it is and what it does
json-logic is a Python implementation of the JsonLogic format, a language-agnostic way to express conditional logic as JSON. It lets you write rules once and execute them identically in Python, JavaScript, PHP, and other supported languages, making it useful for sharing validation or decision logic between client and server code or storing rules in a database alongside data.
The package provides a single main function, jsonLogic, which takes a rule object (and optionally a data object) and returns the result of evaluating that rule. Rules use a prefix notation where the operator is the key and operands are the value—for example, {"==": [1, 1]} evaluates to True. It supports comparison operators, logical operators (and, or, not), variable references (var), and nested rule composition. No external dependencies are required.
Use it for:
- Store validation or authorization rules in a database and execute them server-side without code deployment
- Share conditional business logic between a JavaScript front-end and Python back-end using the same JSON rule format
- Build a rules engine for A/B testing, feature flags, or dynamic pricing without writing conditional code
- Serialize complex decision trees as JSON for configuration files or API responses that clients can also interpret
- Implement user-defined filters or queries in a web application by accepting JsonLogic rules from the client
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Parses and executes JsonLogic rules—a JSON-serializable format for expressing conditional logic—allowing you to share the same rules across front-end and back-end code regardless of language.
Yes, if you need a lightweight, language-agnostic rules engine and can accept dormant maintenance. The package has no dependencies, installs easily, and works for straightforward JsonLogic evaluation. However, verify compatibility with your Python version (classifiers list only up to 3.4) and be aware that no active maintenance means no bug fixes or feature updates—suitable for stable, self-contained use cases but risky if you depend on ongoing support.
Install
json-logic on PyPI
pip
pip install json-logicuv
uv add json-logicpoetry
poetry add json-logicInstalling json-logic
Before you install
Installation is straightforward with no runtime dependencies. The package is dormant (last release 2015-12-04, last commit 2023-12-19), so expect no active maintenance, though the repository remains unarchived.
License in practice
Licensed under MIT (permissive), so you can use, modify, and distribute this package freely in commercial and private projects with minimal restrictions.
Quickstart
pip install json-logic
from json_logic import jsonLogic
rules = {"==": [1, 1]}
result = jsonLogic(rules)
# True
rules = {"var": "name"}
data = {"name": "Alice"}
result = jsonLogic(rules, data)
# "Alice"
Verify before relying
- Whether the package works reliably with modern Python versions beyond those listed in classifiers (3.4 and earlier)
- Whether the dormant status and lack of recent releases pose compatibility risks with current ecosystems
Package facts
| License | MIT (permissive) |
| Python support | not specified |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | none |
| Maintenance | dormant — 3,906 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 2,515,893/month — #3,029 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: json_logic-0.6.3-py2.py3-none-any.whl
Keywords: json-logic
Tags
More Python Modules packages
Converts domain names between Unicode and…
permissive · top 100 on PyPI
setuptoolsSetuptools is a Python build backend and…
permissive · top 100 on PyPI
PyYAMLPyYAML parses and emits YAML 1.1 data format,…
permissive · top 100 on PyPI
pydanticPydantic validates Python data structures…
permissive · top 100 on PyPI
annotated-typesProvides reusable metadata objects for use with…
permissive · top 100 on PyPI
typing-inspectionProvides runtime tools to inspect and…
permissive · top 100 on PyPI
business-rulesA Python DSL for defining business rules as…
permissive · top 15,000 on PyPI
json_logic_qubitParses and executes JsonLogic rules—a…
permissive · top 15,000 on PyPI
panzi-json-logicEvaluates JsonLogic and CertLogic…
permissive · top 15,000 on PyPI
zen-enginezen-engine is a Python binding for a Rust-based…
unclear · top 15,000 on PyPI
robotframework-jsonlibraryA Robot Framework library for querying, adding,…
permissive · top 15,000 on PyPI
jsonableProvides an abstract base class for defining…
permissive · top 15,000 on PyPI
logical-unificationLogical unification in Python with support for…
permissive · top 5,000 on PyPI
rulesrules provides object-level permission checking…
permissive · top 15,000 on PyPI
plyaraParses YARA rule files into Python dictionary…
permissive · top 15,000 on PyPI
skope-rulesSkope-rules learns interpretable logical rules…
permissive · top 15,000 on PyPI