On this page
Sommatic Docs
Open portal

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.

View as Markdown
Open in

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.

HelperReturns
$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.

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.

JavaScript
{{ $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.

JavaScript
{{ $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.

JavaScript
{{ $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.

JavaScript
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.

JavaScript
{{ $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:

OptionDefaultMeaning
length15Number of random characters
prefix'id-'Text placed before them
JavaScript
{{ $randomId({ length: 8, prefix: 'ord-' }) }}
// → ord-3f9a01c2
{{ $randomId({}) }}
// → id- followed by 15 characters

For a standard UUID, use $uuid.

Libraries

LibraryHow you call itReference
lodash_, for example _.sumBy($json.items, 'qty') or _.get($json, 'a.b', 0)lodash
LuxonThrough $now and $today, for example $now.plus({ days: 1 }).toISODate()Luxon
JMESPathThrough $jmespath(object, query)JMESPath
JSONataIn JSONata fields, not inside bracesJSONata functions
JavaScript
{{ _.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…).

JavaScript
{{ 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.

Next steps

Install agent tools

Give your coding agent the official Sommatic AI docs: skills, the docs MCP server and Markdown pages, so it never has to scrape the site.

Skills only. They do not update by themselves; run it again to refresh.

npx skills add https://docs.sommatic.ai
How agents read these docs