Skip to content

JEXL Language Guide ​

JEXL (JavaScript Expression Language) is a powerful expression language for evaluating expressions within JSON structures and JavaScript applications. This guide covers the complete JEXL syntax and language features.

What is JEXL? ​

JEXL provides a simple, yet powerful syntax for:

  • Data transformation - Transform objects and arrays
  • Filtering - Select data based on conditions
  • Calculations - Perform mathematical operations
  • String manipulation - Process and format text
  • Conditional logic - Make decisions in expressions

Language Sections ​

Syntax Overview ​

Learn the basic JEXL syntax, expression structure, and evaluation rules.

Data Types ​

Understand JEXL's data types: strings, numbers, booleans, arrays, objects, and null.

Operators ​

Complete reference for all JEXL operators including arithmetic, comparison, logical, and more.

Expressions ​

Learn how to write complex expressions using functions, transforms, and nested operations.

Context and Variables ​

Understand how JEXL accesses data through context variables and property paths.

Quick Examples ​

Basic Expression ​

javascript
// Simple property access
name
// Returns the 'name' property from context

Array Operations ​

javascript
// Filter and transform array
users|filter("value.age > 21")|map("value.name")
// Filters users by age, then extracts names

Mathematical Calculations ​

javascript
// Calculate percentage
(score / maxScore) * 100
// Calculates percentage from score and maxScore

String Processing ​

javascript
// Clean and format text
title | trim | lowercase | replace(" ", "-")
// Cleans title and converts to slug format

Conditional Logic ​

javascript
// Conditional expression
age >= 18 ? "adult" : "minor"
// Returns status based on age

Key Concepts ​

Expressions vs Statements ​

JEXL uses expressions that always return a value, not statements. Every JEXL expression evaluates to a result.

Context-Driven ​

JEXL expressions are evaluated against a context - a JavaScript object that provides the data for the expression.

Functional Style ​

JEXL encourages a functional programming style with transforms (pipe operations) that chain data transformations.

Type Flexibility ​

JEXL handles JavaScript's dynamic typing, automatically converting between types when needed.

Getting Started ​

  1. Start with Syntax - Learn the basic JEXL syntax
  2. Explore Data Types - Understand how JEXL handles different data types
  3. Master Operators - Learn all available operators
  4. Practice Expressions - Build complex expressions
  5. Understand Context - Learn how data flows through expressions

Ready to dive in? Start with the Syntax Overview!

Released under the MIT License.