--- id: json-logic version: "0.6.3" license: MIT license_treatment: permissive maintenance: dormant --- # json-logic — Build complex rules, serialize them as JSON, and execute them in Python License: permissive · Maintenance: dormant · Downloads: 2.5M/mo ## 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 above — 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 pip install json-logic uv add json-logic 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: unspecified - Install friction: low - Maintenance: dormant - Downloads: 2.5M/month (top 5,000 on PyPI) - Known vulnerabilities: none known ## Tags json logic rules execution, serialize logic as json, cross-language rule engine, conditional logic in json format, jsonlogic parser python, shared rules front-end backend, json-based rule evaluation, rules-engine, cross-language, json-serializable [View on SkillFed](https://skillfed.io/packages/json-logic) · [View on PyPI](https://pypi.org/project/json-logic/)