Jexl is a powerful context-based expression parser and evaluator for JavaScript, enabling safe evaluation of expressions against a context object. Version 2.3.0 is the latest stable release; the library is mature with infrequent updates. Unlike newer alternatives like jsonpath-plus or JMESPath, Jexl supports sync and async evaluation, custom transforms, functions, and binary operators, making it extensible for complex filtering, math, string concatenation, and conditional logic. It works in Node.js and browser (bundled), with no dependencies. The API uses both Promise-based eval and synchronous evalSync, plus a tagged template literal for compiling reusable expressions.
npm install jexlNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Demonstrates Jexl's core features: async eval, sync eval, custom transforms, and expression compilation.
Use import statements or a bundler that handles ESM. For Node <12.17.0, stick with Jexl v1.x.
Use the default import jexl instead of new Jexl(). If you need isolation, create a new instance with import { Jexl } from 'jexl'; const myJexl = new Jexl()Use eval for async expressions, or ensure all transforms/operators are synchronous when using evalSync.
Replace old transform configuration with jexl.addTransform(name, fn).
Add parentheses explicitly: '2^(3*4)' to get the v1 behavior.
Replace jexl.eval('list[reject(.active)]') with jexl.eval('list[.!active]') or similar.Upgrade Node to >=12.22.0 or use import with a bundler. Alternatively, downgrade to jexl@1.
Use default import: import jexl from 'jexl' or require('jexl').Check that the context object includes the required nested structure. Use optional chaining in expressions if needed, but Jexl does not support ?. - add a custom binary operator instead.
Wrap problematic expressions in try/catch or add a custom operator to handle division by zero.
Avoid circular structures in context, or limit expression depth. Use a deep-copy library to sanitize context.
No dependency data recorded yet.