simpleeval
A simple, safe single expression evaluator library.
Decision gist · record as of 2026-08-14
Yes. The package is mature, has no dependencies, carries no known vulnerabilities, and solves a real security problem—allowing safe user-defined expressions. Install it if you need to evaluate untrusted formulas; avoid it only if you need features beyond basic arithmetic, comparisons, and simple function calls, or if you're not concerned about the security implications of eval().AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Requires Python 3.9 or later.
- No runtime dependencies and a single-file design keep installation friction minimal.
- The package is actively maintained with a recent release, and has been stable since its initial 2014 release.
License · maintenance · safety
MIT (permissive) — MIT license is permissive and imposes no restrictions on use, modification, or distribution in commercial or private projects.
last release 2026-03-16 (151 days) · last repo commit 2026-08-07 · 612 stars
0 known vulnerabilities (OSV.dev, 2026-08-14) · 15,002,011 downloads/mo, #1,206 on PyPI
Alternatives
Verify before relying
from simpleeval import simple_eval
result = simple_eval("21 + 21")
print(result) # 42
# With custom functions
result = simple_eval("square(11)", functions={"square": lambda x: x*x})
print(result) # 121- Whether the default MAX_POWER limit of 4000000 and MAX_STRING_LENGTH of 100000 characters are appropriate for your use case.
- Whether the package's DOS protection against long-running or memory-intensive expressions is sufficient for your deployment context.
What it is and what it does
simpleeval is a lightweight library that safely evaluates mathematical and logical expressions provided as strings, without exposing the full power and security risks of Python's eval(). It uses Python's ast module to parse expressions and enforce strict limits on what operations are allowed, making it suitable for scenarios where you want to let users or configuration systems define formulas—such as setting alarm volumes based on time of day, or allowing simple math in web forms—without granting arbitrary code execution.
The library comes with sensible defaults: basic arithmetic, comparison, and bitwise operators; a handful of utility functions like randint(), int(), float(), and str(); and configurable limits on exponentiation and string length to prevent denial-of-service attacks. You can extend it by passing custom functions and variables (called 'names') into the evaluator, or by replacing operators entirely. It's deliberately kept simple and single-file, so you can even embed it directly in a project if you prefer not to add a dependency.
Use it for
- Allow users to define alarm volume rules that depend on time of day, alarm level, and other state without risking code injection.
- Accept simple mathematical formulas in web forms or configuration files and evaluate them safely server-side.
- Build rule engines or conditional logic systems where non-technical users can write expressions like 'if x > 10 then y else z'.
- Implement dynamic pricing or discount calculations in e-commerce systems based on user-provided or admin-configured formulas.
- Parse and evaluate mathematical expressions in scientific or educational applications without the security overhead of full eval().
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
Yes.
The package is mature, has no dependencies, carries no known vulnerabilities, and solves a real security problem—allowing safe user-defined expressions. Install it if you need to evaluate untrusted formulas; avoid it only if you need features beyond basic arithmetic, comparisons, and simple function calls, or if you're not concerned about the security implications of eval().
Install
simpleeval on PyPI
Before you install
No runtime dependencies and a single-file design keep installation friction minimal. The package is actively maintained with a recent release, and has been stable since its initial 2014 release.
Requires Python 3.9 or later.
License in practice
MIT license is permissive and imposes no restrictions on use, modification, or distribution in commercial or private projects.
Quickstart
from simpleeval import simple_eval
result = simple_eval("21 + 21")
print(result) # 42
# With custom functions
result = simple_eval("square(11)", functions={"square": lambda x: x*x})
print(result) # 121
Verify before relying
- Whether the default MAX_POWER limit of 4000000 and MAX_STRING_LENGTH of 100000 characters are appropriate for your use case.
- Whether the package's DOS protection against long-running or memory-intensive expressions is sufficient for your deployment context.
Package facts
| License | MIT permissive |
| Python support | Supports the current Python release >=3.9 |
| Install friction | Low. Pure-Python wheel |
| Runtime dependencies | None |
| Maintenance | Actively maintained 151 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 15,002,011 / month, #1,206 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
| Classifiers | Development Status :: 5 - Production/StableIntended Audience :: DevelopersLicense :: OSI Approved :: MIT LicenseProgramming Language :: PythonTopic :: Software Development :: Libraries :: Python Modules |
Evidence: simpleeval-1.0.7-py3-none-any.whl
Tags
Let your AI agent find packages like this
Example. Real query, live index.
You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.
wish › “formula parser without eval”
- simpleevalEvaluates mathematical and logical expressions from strings in a…
- astevalAsteval is a safe Python expression and statement evaluator that uses…
- patsyPatsy converts R-style statistical formulas into design matrices for…
Give your agent the search over MCP, or paste the wish link into any chat.
More Python Modules packages
Converts domain names between Unicode and ASCII-compatible encoding (Punycode) according to IDNA 2008 and Unicode Technical Standard 46, with security validation and broader script coverage than the standard library.
Install it if you work with internationalized domain names, need to validate domains, or use HTTP clients that depend on it transitively.
Setuptools is a Python build backend and package management tool that handles building, distributing, and installing Python packages, including support for C/C++ extension modules.
PyYAML parses and emits YAML 1.1 data format, enabling serialization and deserialization of configuration files and Python objects to and from human-readable YAML text.
Pydantic validates Python data structures against type hints, coercing and checking input at runtime to ensure it matches a declared schema.
Provides reusable metadata objects for use with PEP-593 `typing.Annotated` to express common constraints like bounds, collection sizes, and predicates on types.
Install it if you use or build libraries that need to express type constraints in a standardized, inspectable way—or if you want to annotate your own types with…
Provides runtime tools to inspect and introspect Python type annotations, enabling programmatic examination of type hints at execution time.
See also asteval · leval · py-expression-eval · pure-eval · tag-expressions · cel-expr-python · boolean.py · cel-python · common-expression-language · math-verify