skillfed

json-logic

Build complex rules, serialize them as JSON, and execute them in Python

json-logic v0.6.3 2.5M downloads/30d#3,029 on PyPI226
Permissive license MIT DORMANT released

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-logic

uv

uv add json-logic

poetry

poetry add json-logic

Installing 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

Development Status :: 4 - BetaIntended Audience :: DevelopersLicense :: OSI Approved :: MIT LicenseProgramming Language :: Python :: 2Programming Language :: Python :: 2.6Programming Language :: Python :: 2.7Programming Language :: Python :: 3Programming Language :: Python :: 3.2Programming Language :: Python :: 3.3Programming Language :: Python :: 3.4Topic :: Software Development :: Libraries :: Python Modules

Tags

json logic rules executionserialize logic as jsoncross-language rule engineconditional logic in json formatjsonlogic parser pythonshared rules front-end backendjson-based rule evaluation
rules-enginecross-languagejson-serializable

More Python Modules packages