Helpers
The helper functions an expression can call — JMESPath queries, defaults for empty values, slugs, query strings, Base64 and random ids — plus lodash, Luxon and the JavaScript built-ins.
Helpers are functions available in every expression. They cover the small jobs that come up between nodes: choosing a default, building a URL, querying a nested response, encoding a value.
| Helper | Returns |
|---|---|
$jmespath(object, query) | The result of a JMESPath query |
$ifEmpty(value, fallback) | value, or fallback when value is empty |
$isEmpty(object) | true when the object has no keys |
$slugify(text) | A lowercase, hyphenated slug |
$toQueryString(object) | A query string that starts with ? |
$base64Encode(value) | URL-safe Base64 text |
$base64Decode(text) | The decoded text |
$randomId(options) | A random id with a prefix |
$jmespath(object, query)
Runs a JMESPath query over any object and returns what it selects. It shines with deep API responses, where a query is shorter than a chain of JavaScript.
{{ $jmespath($json, 'items[?qty > `0`].sku') }}
{{ $jmespath($('Fetch order').item.json, 'lines[0].product.name') }}
{{ $jmespath($json, 'length(items)') }}JMESPath literals go between backticks inside the query, as in `0` above.
$ifEmpty(value, fallback)
Returns fallback when value is undefined, null, an empty string, an empty list or an object without keys;
otherwise returns value. 0 and false are kept.
{{ $ifEmpty($json.body.priority, 'normal') }}
{{ $ifEmpty($('Find customer').item.json.segment, 'unassigned') }}$isEmpty(object)
Returns true when the object has no own keys. It only looks at the first level: { a: {} } is not empty.
{{ $isEmpty($json.body.attachments_meta) }}For strings, null or undefined, prefer $ifEmpty.
$slugify(text)
Turns any text into a lowercase slug with hyphens, without accents.
{{ $slugify('Hola Mundo Ñandú 2026') }}
// → hola-mundo-nandu-2026$toQueryString(object)
Builds a query string from an object, encoding keys and values. Nested objects use brackets (filter[status]=open,
encoded). The result starts with ?, so you can append it to a URL.
https://api.example.com/orders{{ $toQueryString({ status: 'open', page: 2 }) }}
// → https://api.example.com/orders?status=open&page=2$base64Encode(value) and $base64Decode(text)
$base64Encode encodes a string, or an object serialized as JSON, with the URL-safe alphabet (- and _ instead of
+ and /) and without = padding. $base64Decode returns the decoded text. Both return an empty string for an
empty value.
{{ $base64Encode('Sommatic') }}
// → U29tbWF0aWM
{{ $base64Encode({ id: $json.id }) }}
// → eyJpZCI6N30 when id is 7
{{ $base64Decode($json.body.state) }}When a service requires standard Base64 with padding, convert the value in a code node.
$randomId(options)
Returns a prefix followed by random hexadecimal characters. Always pass the options object:
| Option | Default | Meaning |
|---|---|---|
length | 15 | Number of random characters |
prefix | 'id-' | Text placed before them |
{{ $randomId({ length: 8, prefix: 'ord-' }) }}
// → ord-3f9a01c2
{{ $randomId({}) }}
// → id- followed by 15 charactersFor a standard UUID, use $uuid.
Libraries
| Library | How you call it | Reference |
|---|---|---|
| lodash | _, for example _.sumBy($json.items, 'qty') or _.get($json, 'a.b', 0) | lodash |
| Luxon | Through $now and $today, for example $now.plus({ days: 1 }).toISODate() | Luxon |
| JMESPath | Through $jmespath(object, query) | JMESPath |
| JSONata | In JSONata fields, not inside braces | JSONata functions |
{{ _.pick($json, ['id', 'status']) }}
{{ _.uniq($json.tags) }}
{{ _.groupBy($json.items, 'category') }}JavaScript built-ins
Expressions can use Math, JSON, Date, String, Number, Boolean, Array and Object, and every method of
strings, numbers, lists and objects (split, toUpperCase, padStart, map, filter, reduce, Object.keys…).
{{ Number($json.amount) * 1.19 }}
{{ String($json.id).padStart(6, '0') }}
{{ encodeURIComponent($json.key) }}To convert text to a number, use Number(…). Avoid I/O: an expression cannot call services or read files; use
io.http or a code node.