A TypeScript implementation of the popular Symfony Expression Language! This library allows you to evaluate complex expressions client-side, fully mirroring the functionality of the PHP version.
Use it to create dynamic and flexible expression-based logic on the frontend while keeping it in sync with your Symfony/PHP backend.
Features
- Full Symfony Compatibility — Works just like Symfony’s Expression Language.
- Rich Syntax — Supports numbers, strings, operators, functions, and object/array access.
- Custom Functions — Extend functionality by registering your own functions.
- TypeScript Support — Fully typed, making it seamless to use in TS projects.
- Client-Side Execution — Evaluate expressions directly in the browser.
Installation
npm install @andreasnicolaou/typescript-expression-language
For full usage details and API documentation, visit the official npm page:
Why Use This Library?
- Eliminate Duplicate Logic — Write expressions once and use them both client-side and server-side.
- Consistent Behavior — Ensure frontend and backend calculations match perfectly.
- Lightweight & Fast — Optimized for speed, with minimal dependencies.
- Safe (no eval, uses AST)
- You can add custom functions & operators
- Great for UI features, use in feature flags, search filters, validation rules, dashboards, etc
- Dynamic rules without code changes, let users/admins define filters, formulas, or conditions in text.
Get Started Today!
This library is open-source and actively maintained! If you find it useful, consider giving it a ⭐️ on GitHub: expression-language
Install via npm at: expression-language
Top comments (0)