On this page
Sommatic Docs
Open portal

JavaScript Globals

The standard JavaScript functions and objects an expression can use (Math, JSON, text, numbers, lists, objects, dates, regular expressions, Intl), with what each returns, and the Node APIs that do not exist.

View as Markdown
Open in

Expressions run on Node 22 in an isolated context: the ECMAScript standard library is there, Node is not (no require, process, network or timers). Methods marked Node 22 are recent additions. Every example was run against the deployed engine over the example context at the end of the page.

Global functions

Standard ECMAScript functions available without a namespace: URL encoding and number parsing.

encodeURIComponent(text) → string

Encodes a value for safe use inside one URL component (a query value or path segment), escaping &, =, /, ? and spaces.

{{ 'https://example.com/search?q=' + encodeURIComponent($json.body.key) }}
Result string
"https://example.com/search?q=a%20b%26c"
decodeURIComponent(text) → string

Decodes text produced by encodeURIComponent; throws URIError on a malformed % sequence.

{{ decodeURIComponent($json.body.query.split('=')[1]) }}
Result string
"Ana Pérez"
encodeURI(text) → string

Encodes a complete URL but keeps reserved characters such as :, /, ? and &; do not use it for single parameter values.

{{ encodeURI('https://example.com/files/' + $json.body.name + '.pdf') }}
Result string
"https://example.com/files/ana%20p%C3%A9rez.pdf"
decodeURI(text) → string

Decodes a complete URL encoded with encodeURI; escapes that stand for reserved characters stay encoded.

{{ decodeURI('https://example.com/files/ana%20p%C3%A9rez.pdf') }}
Result string
"https://example.com/files/ana pérez.pdf"
parseInt(text, radix?) → number

Reads the leading integer of a text and stops at the first invalid character; always pass the radix (10), and expect NaN when the text does not start with a digit.

{{ parseInt($json.body.qty, 10) }}
Result number
3
parseFloat(text) → number

Reads the leading decimal number of a text; only . is accepted as decimal separator, so "1.234,5" becomes 1.234.

{{ parseFloat($json.body.total) }}
Result number
1234.5
isNaN(value) → boolean

Returns true when the value is NaN after being coerced to a number, so isNaN("abc") is true; use Number.isNaN for a check without coercion.

{{ isNaN($json.body.total) }}
Result boolean
false
isFinite(value) → boolean

Returns true when the value, coerced to a number, is finite (isFinite("12") is true); use Number.isFinite to avoid coercion.

{{ isFinite($json.body.total) }}
Result boolean
true

Math

Static numeric functions and constants. Angles are in radians, and every function returns NaN when an argument is not numeric.

Math.E → number

Euler's number, the base of natural logarithms (≈ 2.718).

{{ Math.E ** $json.body.score }}
Result number
2.395040162420149
Math.LN2 → number

Natural logarithm of 2 (≈ 0.693).

{{ Math.log($json.body.count) / Math.LN2 }}
Result number
5.392317422778761
Math.LN10 → number

Natural logarithm of 10 (≈ 2.303).

{{ Math.log($json.body.count) / Math.LN10 }}
Result number
1.6232492903979003
Math.LOG2E → number

Base-2 logarithm of e (≈ 1.443).

{{ Math.LOG2E * Math.log($json.body.count) }}
Result number
5.392317422778761
Math.LOG10E → number

Base-10 logarithm of e (≈ 0.434).

{{ Math.LOG10E * Math.log($json.body.count) }}
Result number
1.6232492903979006
Math.PI → number

Ratio of a circle's circumference to its diameter (≈ 3.14159).

{{ Math.PI * $json.body.radius ** 2 }}
Result number
12.566370614359172
Math.SQRT1_2 → number

Square root of 1/2 (≈ 0.707).

{{ Math.SQRT1_2 * $json.body.radius }}
Result number
1.4142135623730951
Math.SQRT2 → number

Square root of 2 (≈ 1.414).

{{ Math.SQRT2 * $json.body.radius }}
Result number
2.8284271247461903
Math.abs(x) → number

Absolute value of a number.

{{ Math.abs($json.body.amount - 1300) }}
Result number
65.43299999999999
Math.acos(x) → number

Arccosine in radians, for x between -1 and 1.

{{ Math.acos($json.body.score) }}
Result number
0.508655649762903
Math.acosh(x) → number

Hyperbolic arccosine, for x greater than or equal to 1.

{{ Math.acosh($json.body.count) }}
Result number
4.430675045349548
Math.asin(x) → number

Arcsine in radians, for x between -1 and 1.

{{ Math.asin($json.body.score) * 180 / Math.PI }}
Result number
60.85617804310109
Math.asinh(x) → number

Hyperbolic arcsine.

{{ Math.asinh($json.body.score) }}
Result number
0.7889641252267557
Math.atan(x) → number

Arctangent in radians, between -π/2 and π/2.

{{ Math.atan($json.body.score) }}
Result number
0.7179230860695903
Math.atan2(y, x) → number

Angle in radians from the positive x axis to the point (x, y); note that y comes first.

{{ Math.atan2($json.body.lat, $json.body.lon) * 180 / Math.PI }}
Result number
176.36087870201794
Math.atanh(x) → number

Hyperbolic arctangent, for x between -1 and 1.

{{ Math.atanh($json.body.score) }}
Result number
1.347238865532477
Math.cbrt(x) → number

Cube root; works with negative numbers.

{{ Math.cbrt($json.body.count) }}
Result number
3.4760266448864496
Math.ceil(x) → number

Rounds up to the next integer.

{{ Math.ceil($json.items.length / 2) }}
Result number
2
Math.clz32(x) → number

Number of leading zero bits in the 32-bit unsigned representation of x.

{{ Math.clz32($json.body.count) }}
Result number
26
Math.cos(x) → number

Cosine of an angle in radians.

{{ Math.cos($json.body.lon * Math.PI / 180) }}
Result number
0.2744275031057714
Math.cosh(x) → number

Hyperbolic cosine.

{{ Math.cosh($json.body.score) }}
Result number
1.40628484759911
Math.exp(x) → number

e raised to the power x.

{{ Math.exp(-$json.body.retries) }}
Result number
0.1353352832366127
Math.expm1(x) → number

e^x - 1, accurate for values of x close to 0.

{{ Math.expm1($json.body.discount) }}
Result number
0.16183424272828312
Math.floor(x) → number

Rounds down toward -Infinity, so Math.floor(-1.5) is -2.

{{ Math.floor($json.body.amount) }}
Result number
1234
Math.fround(x) → number

Nearest 32-bit single-precision float to x.

{{ Math.fround($json.body.amount) }}
Result number
1234.5670166015625
Math.hypot(...values) → number

Square root of the sum of the squares of its arguments.

{{ Math.hypot($json.body.lat, $json.body.lon) }}
Result number
74.22175906976338
Math.imul(a, b) → number

32-bit integer multiplication with overflow, as in C; useful for simple hash functions.

{{ Math.imul($json.body.count, 31) }}
Result number
1302
Math.log(x) → number

Natural logarithm; -Infinity for 0 and NaN for negative numbers.

{{ Math.log($json.body.count) }}
Result number
3.7376696182833684
Math.log10(x) → number

Base-10 logarithm.

{{ Math.floor(Math.log10($json.body.amount)) + 1 }}
Result number
4
Math.log1p(x) → number

Natural logarithm of 1 + x, accurate for values of x close to 0.

{{ Math.log1p($json.body.discount) }}
Result number
0.13976194237515868
Math.log2(x) → number

Base-2 logarithm.

{{ Math.ceil(Math.log2($json.items.length)) }}
Result number
2
Math.max(...values) → number

Largest of its arguments; spread an array with ..., and note it returns -Infinity with no arguments.

{{ Math.max(...$json.items.map(item => item.price)) }}
Result number
120
Math.min(...values) → number

Smallest of its arguments; spread an array with ..., and note it returns Infinity with no arguments.

{{ Math.min(...$json.items.map(item => item.price)) }}
Result number
19.99
Math.pow(base, exponent) → number

base raised to exponent, the same as the ** operator.

{{ Math.pow(1 + $json.body.discount, 2) }}
Result number
1.3224999999999998
Math.random() → number

Pseudo-random number in [0, 1); it changes on every run, so avoid it where the result must be reproducible and use $uuid for identifiers.

{{ Math.floor(Math.random() * 1000) }}
Result number
435
Math.round(x) → number

Rounds to the nearest integer, with .5 going toward +Infinity (Math.round(-2.5) is -2); for two decimals use Math.round(x * 100) / 100.

{{ Math.round($json.body.amount * 100) / 100 }}
Result number
1234.57
Math.sign(x) → number

Returns 1, -1, 0 or -0 according to the sign of x.

{{ Math.sign($json.body.amount - 1000) }}
Result number
1
Math.sin(x) → number

Sine of an angle in radians.

{{ Math.sin($json.body.lat * Math.PI / 180) }}
Result number
0.08212984776112466
Math.sinh(x) → number

Hyperbolic sine.

{{ Math.sinh($json.body.score) }}
Result number
0.9887553148210393
Math.sqrt(x) → number

Square root; NaN for negative numbers.

{{ Math.sqrt($json.body.count) }}
Result number
6.48074069840786
Math.tan(x) → number

Tangent of an angle in radians.

{{ Math.tan($json.body.lat * Math.PI / 180) }}
Result number
0.08240825272117056
Math.tanh(x) → number

Hyperbolic tangent, between -1 and 1.

{{ Math.tanh($json.body.score) }}
Result number
0.703097467422122
Math.trunc(x) → number

Drops the fractional part, rounding toward zero (Math.trunc(-1.5) is -1).

{{ Math.trunc(-$json.body.amount) }}
Result number
-1234

JSON

Convert between JSON text and values. Use it to read string payloads and to build request bodies.

JSON.parse(text, reviver?) → any

Parses JSON text into a value; invalid JSON throws SyntaxError and the expression fails.

{{ JSON.parse($json.body.payload).sku }}
Result string
"SKU-1"
JSON.stringify(value, replacer?, indent?) → string

Serializes a value to JSON text; drops undefined and functions, turns Map and Set into {}, writes dates as ISO text, and throws on circular references.

{{ JSON.stringify($json.items.map(item => item.sku)) }}
Result string
"[\"SKU-1\",\"SKU-2\",\"SKU-3\"]"

Number

Conversion, checks and formatting for numbers. Values that arrive as text (form fields, query strings, CSV) must be converted before doing arithmetic.

Number(value) → number

Converts a value to a number: "" and null become 0 and any non-numeric text becomes NaN; unlike parseFloat, the whole text must be numeric.

{{ Number($json.body.total) * Number($json.body.qty) }}
Result number
3703.5
Number.isFinite(value) → boolean

Returns true only for finite values of type number, without coercion.

{{ Number.isFinite(Number($json.body.total)) }}
Result boolean
true
Number.isInteger(value) → boolean

Returns true when the value is a number with no fractional part.

{{ Number.isInteger($json.body.count) }}
Result boolean
true
Number.isNaN(value) → boolean

Returns true only when the value is exactly NaN, without coercion; use it after Number() to detect invalid input.

{{ Number.isNaN(Number($json.body.qty)) }}
Result boolean
false
Number.isSafeInteger(value) → boolean

Returns true for integers between ±(2^53 − 1); larger numeric ids lose precision, so keep them as text.

{{ Number.isSafeInteger($json.body.count) }}
Result boolean
true
Number.parseFloat(text) → number

Same function as the global parseFloat.

{{ Number.parseFloat($json.body.total) }}
Result number
1234.5
Number.parseInt(text, radix?) → number

Same function as the global parseInt; always pass the radix.

{{ Number.parseInt($json.body.code.split('-')[1], 10) }}
Result number
123
Number.EPSILON → number

Smallest difference between 1 and the next representable number (2^-52); use it as tolerance when comparing decimals.

{{ Math.abs($json.items[0].price * 2 - 91) < Number.EPSILON }}
Result boolean
true
Number.MAX_SAFE_INTEGER → number

Largest integer that can be represented exactly (2^53 − 1 = 9007199254740991).

{{ $json.body.count <= Number.MAX_SAFE_INTEGER }}
Result boolean
true
Number.MIN_SAFE_INTEGER → number

Smallest integer that can be represented exactly (−(2^53 − 1)).

{{ -$json.body.count >= Number.MIN_SAFE_INTEGER }}
Result boolean
true
Number.MAX_VALUE → number

Largest finite number (≈ 1.8e308).

{{ $json.body.amount < Number.MAX_VALUE }}
Result boolean
true
Number.MIN_VALUE → number

Smallest positive number greater than 0 (≈ 5e-324), not the most negative number.

{{ $json.body.discount > Number.MIN_VALUE }}
Result boolean
true
Number.NaN → number

The "not a number" value; it is not equal to itself, so test it with Number.isNaN.

{{ $json.body.total ? Number($json.body.total) : Number.NaN }}
Result number
1234.5
Number.POSITIVE_INFINITY → number

Positive infinity, larger than any number; handy as an "unlimited" default.

{{ $json.body.limit ?? Number.POSITIVE_INFINITY }}
Result number
null
Number.NEGATIVE_INFINITY → number

Negative infinity, smaller than any number; handy as the starting value when looking for a maximum.

{{ $json.items.reduce((max, item) => Math.max(max, item.price), Number.NEGATIVE_INFINITY) }}
Result number
120
number.toExponential(digits?) → string number

Formats the number in exponential notation and returns text.

{{ $json.body.amount.toExponential(2) }}
Result string
"1.23e+3"
number.toFixed(digits?) → string number

Formats with a fixed number of decimals and returns text, not a number; wrap it in Number() if you keep calculating.

{{ $json.body.amount.toFixed(2) }}
Result string
"1234.57"
number.toLocaleString(locale?, options?) → string number

Formats the number with the separators of a locale (uses Intl.NumberFormat); pass the locale explicitly, since the default is the server's.

{{ $json.body.amount.toLocaleString('es-CO', { maximumFractionDigits: 0 }) }}
Result string
"1.235"
number.toPrecision(precision?) → string number

Formats with a given number of significant digits and returns text; may switch to exponential notation.

{{ $json.body.score.toPrecision(2) }}
Result string
"0.87"
number.toString(radix?) → string number

Converts the number to text in the given base (2 to 36, default 10).

{{ $json.body.count.toString(16) }}
Result string
"2a"

String

Text conversion and the methods available on every text value. Text is immutable: every method returns a new value and leaves the original unchanged.

String(value) → string

Converts any value to text; null becomes "null" and objects become "[object Object]", so use JSON.stringify for objects.

{{ String($json.body.count).padStart(6, '0') }}
Result string
"000042"
String.fromCharCode(...codes) → string

Builds text from UTF-16 code units.

{{ String.fromCharCode(65 + $json.items.length) }}
Result string
"D"
String.fromCodePoint(...codePoints) → string

Builds text from Unicode code points, including characters outside the basic plane such as emoji.

{{ String.fromCodePoint(0x2713) + ' ' + $json.body.order_id }}
Result string
"✓ ORD-1042"
String.raw`template` → string

Template tag that returns the text without processing backslash escapes; handy for regular expressions and Windows paths.

{{ new RegExp(String.raw`^ORD-\d+$`).test($json.body.order_id) }}
Result boolean
true
text.length → number text

Number of UTF-16 code units in the text; an emoji can count as 2.

{{ $json.body.order_id.length }}
Result number
8
text.at(index) → string text

Character at index; negative values count from the end, and out-of-range indexes return undefined.

{{ $json.body.order_id.at(-1) }}
Result string
"2"
text.charAt(index) → string text

Character at index, or "" when the index is out of range.

{{ $json.body.name.charAt(0).toUpperCase() + $json.body.name.slice(1) }}
Result string
"Ana pérez"
text.charCodeAt(index) → number text

UTF-16 code unit at index (0 to 65535), or NaN when out of range.

{{ $json.body.code.charCodeAt(0) }}
Result number
97
text.codePointAt(index) → number text

Unicode code point that starts at index, or undefined when out of range.

{{ $json.body.name.codePointAt(5) }}
Result number
233
text.concat(...texts) → string text

Joins the arguments to the end of the text; the same as using +.

{{ $json.body.order_id.concat('-', $json.customer.country) }}
Result string
"ORD-1042-CO"
text.endsWith(search, length?) → boolean text

Returns true when the text ends with search (case-sensitive).

{{ $json.customer.email.endsWith('@example.com') }}
Result boolean
true
text.includes(search, position?) → boolean text

Returns true when search appears in the text; the comparison is case-sensitive, so normalize the case first.

{{ $json.body.email.toLowerCase().includes('@example.com') }}
Result boolean
true
text.indexOf(search, position?) → number text

Index of the first occurrence of search, or -1 when it is not found.

{{ $json.customer.email.indexOf('@') }}
Result number
3
text.isWellFormed() → boolean text

Returns true when the text contains no lone surrogates, i.e. it can be safely encoded as UTF-8.

{{ $json.body.name.isWellFormed() }}
Result boolean
true
text.lastIndexOf(search, position?) → number text

Index of the last occurrence of search, or -1 when it is not found.

{{ $json.body.url.lastIndexOf('/') }}
Result number
19
text.localeCompare(other, locale?, options?) → number text

Compares two texts by the rules of a locale and returns a negative number, 0 or a positive number; use it in sort to order names with accents correctly.

{{ $json.items.map(item => item.name).sort((a, b) => a.localeCompare(b, 'es')) }}
Result list
["Keyboard","Mouse","Support plan"]
text.match(regexp) → list text

Matches a regular expression: without the g flag it returns the first match with its groups, with g every match; returns null when nothing matches, so guard the result.

{{ ($json.body.url.match(/id=([^&]+)/) || [])[1] }}
Result string
"ORD-1042"
text.matchAll(regexp) → iterator text

Iterator over every match, with groups, of a regex that must have the g flag; spread it into a list with [...].

{{ [...$json.body.url.matchAll(/(\w+)=([^&]+)/g)].map(match => match[1]) }}
Result list
["id","page"]
text.normalize(form?) → string text

Returns the Unicode normalization form (NFC by default); with NFD plus a regex you can strip accents.

{{ $json.body.name.normalize('NFD').replace(/[\u0300-\u036f]/g, '') }}
Result string
"ana perez"
text.padEnd(length, filler?) → string text

Pads the end of the text with filler (a space by default) up to length.

{{ $json.items[0].sku.padEnd(10, '.') }}
Result string
"SKU-1....."
text.padStart(length, filler?) → string text

Pads the start of the text with filler (a space by default) up to length; typical for zero-padded codes.

{{ String($json.body.count).padStart(8, '0') }}
Result string
"00000042"
text.repeat(count) → string text

Repeats the text count times.

{{ '*'.repeat($json.body.order_id.length - 4) + $json.body.order_id.slice(-4) }}
Result string
"****1042"
text.replace(pattern, replacement) → string text

Replaces only the first match when pattern is text; use a regex with the g flag or replaceAll to replace every match. replacement can be a function or use $1 for groups.

{{ $json.body.phone.replace(/\D/g, '') }}
Result string
"573001234567"
text.replaceAll(pattern, replacement) → string text

Replaces every match; when pattern is a regex it must have the g flag, otherwise it throws TypeError.

{{ $json.body.key.replaceAll(' ', '_') }}
Result string
"a_b&c"
text.slice(start, end?) → string text

Extracts the part between start and end (exclusive); negative indexes count from the end.

{{ $json.body.created_at.slice(0, 10) }}
Result string
"2026-11-20"
text.split(separator, limit?) → list text

Splits the text into a list by separator (text or regex).

{{ $json.customer.email.split('@')[1] }}
Result string
"example.com"
text.startsWith(search, position?) → boolean text

Returns true when the text starts with search (case-sensitive).

{{ $json.body.order_id.startsWith('ORD-') }}
Result boolean
true
text.substring(start, end?) → string text

Like slice, but negative indexes are treated as 0 and the arguments are swapped when start > end; prefer slice.

{{ $json.body.order_id.substring(4) }}
Result string
"1042"
text.toLocaleLowerCase(locale?) → string text

Converts to lowercase using the rules of a locale (for example Turkish dotted i).

{{ $json.body.name.toLocaleLowerCase('es-CO') }}
Result string
"ana pérez"
text.toLocaleUpperCase(locale?) → string text

Converts to uppercase using the rules of a locale.

{{ $json.body.name.toLocaleUpperCase('es-CO') }}
Result string
"ANA PÉREZ"
text.toLowerCase() → string text

Converts the text to lowercase; combine it with trim to normalize emails.

{{ $json.body.email.trim().toLowerCase() }}
Result string
text.toUpperCase() → string text

Converts the text to uppercase.

{{ $json.body.status.toUpperCase() }}
Result string
"PAID"
text.toWellFormed() → string text

Returns a copy where every lone surrogate is replaced with U+FFFD, so the text can be encoded as UTF-8.

{{ $json.body.name.toWellFormed() }}
Result string
"ana pérez"
text.trim() → string text

Removes whitespace and line breaks from both ends.

{{ $json.body.email.trim() }}
Result string
text.trimEnd() → string text

Removes whitespace and line breaks from the end.

{{ $json.body.email.trimEnd() }}
Result string
text.trimStart() → string text

Removes whitespace and line breaks from the start.

{{ $json.body.email.trimStart() }}
Result string

Array

List creation and the methods available on every list. Mutating methods (sort, reverse, splice, push, pop, shift, unshift, fill, copyWithin) change the list in $json itself: copy it with [...list] first, or use the non-mutating versions (toSorted, toReversed, toSpliced, with).

Array.isArray(value) → boolean

Reliable check for a list; use it instead of instanceof Array, which returns false for list literals written inside an expression.

{{ Array.isArray($json.items) ? $json.items.length : 0 }}
Result number
3
Array.from(source, mapFn?) → list

Creates a list from an iterable or array-like value (Set, Map, text, { length: n }), optionally mapping each element.

{{ Array.from(new Set($json.body.tags)) }}
Result list
["vip","b2b"]
Array.of(...values) → list

Creates a list from its arguments.

{{ Array.of($json.body.order_id, $json.customer.id) }}
Result list
["ORD-1042","cus_001"]
list.length → number list

Number of elements in the list.

{{ $json.items.length }}
Result number
3
list.at(index) → any list

Element at index; negative values count from the end (at(-1) is the last element).

{{ $json.items.at(-1).sku }}
Result string
"SKU-3"
list.concat(...values) → list list

Returns a new list with the values (or the elements of lists) appended; does not mutate.

{{ $json.items.concat([{ sku: 'SKU-9', qty: 1, price: 5 }]).length }}
Result number
4
list.copyWithin(target, start, end?) → list list

Mutates the list: copies a slice of it over another position and returns the same list.

{{ [...$json.body.tags].copyWithin(0, 1) }}
Result list
["b2b","vip","vip"]
list.entries() → iterator list

Iterator of [index, element] pairs; spread it with [...] to get a list.

{{ [...$json.items.entries()].map(([index, item]) => (index + 1) + '. ' + item.name) }}
Result list
["1. Keyboard","2. Mouse","3. Support plan"]
list.every(predicate) → boolean list

Returns true when predicate is true for every element (and for an empty list).

{{ $json.items.every(item => item.qty > 0) }}
Result boolean
true
list.fill(value, start?, end?) → list list

Mutates the list: sets every position between start and end to value.

{{ new Array($json.items.length).fill(0) }}
Result list
[0,0,0]
list.filter(predicate) → list list

New list with the elements for which predicate returns true.

{{ $json.items.filter(item => item.category === 'hardware') }}
Result list
[
  {
    "sku": "SKU-1",
    "name": "Keyboard",
    "qty": 2,
    "price": 45.5,
    "category": "hardware"
  },
  {
    "sku": "SKU-2",
    "name": "Mouse",
    "qty": 1,
    "price": 19.99,
    "category": "hardware"
  }
]
list.find(predicate) → any list

First element that matches predicate, or undefined; combine it with ?. before reading a field.

{{ $json.items.find(item => item.sku === 'SKU-2')?.price }}
Result number
19.99
list.findIndex(predicate) → number list

Index of the first element that matches predicate, or -1.

{{ $json.items.findIndex(item => item.sku === 'SKU-3') }}
Result number
2
list.findLast(predicate) → any list

Last element that matches predicate, or undefined.

{{ $json.items.findLast(item => item.category === 'hardware').sku }}
Result string
"SKU-2"
list.findLastIndex(predicate) → number list

Index of the last element that matches predicate, or -1.

{{ $json.items.findLastIndex(item => item.category === 'hardware') }}
Result number
1
list.flat(depth?) → list list

New list with nested lists flattened up to depth levels (1 by default).

{{ $json.matrix.flat() }}
Result list
[1,2,3,4]
list.flatMap(fn) → list list

Maps each element and flattens the result one level; return a list to emit several values per element.

{{ $json.items.flatMap(item => Array(item.qty).fill(item.sku)) }}
Result list
["SKU-1","SKU-1","SKU-2","SKU-3"]
list.forEach(fn) → undefined list

Runs fn for each element and returns undefined, so on its own the expression yields nothing; use map or reduce to produce a value.

{{ (() => { let units = 0; $json.items.forEach(item => { units += item.qty; }); return units; })() }}
Result number
4
list.includes(value, fromIndex?) → boolean list

Returns true when the list contains value (finds NaN; objects are compared by reference, not by content).

{{ $json.body.tags.includes('vip') }}
Result boolean
true
list.indexOf(value, fromIndex?) → number list

Index of the first element strictly equal to value, or -1.

{{ $json.body.tags.indexOf('b2b') }}
Result number
1
list.join(separator?) → string list

Joins the elements into text with separator (, by default); null and undefined become empty text.

{{ $json.items.map(item => item.sku).join(', ') }}
Result string
"SKU-1, SKU-2, SKU-3"
list.keys() → iterator list

Iterator of the indexes; spread it with [...] to get a list.

{{ [...$json.items.keys()] }}
Result list
[0,1,2]
list.lastIndexOf(value, fromIndex?) → number list

Index of the last element strictly equal to value, or -1.

{{ $json.body.tags.lastIndexOf('vip') }}
Result number
2
list.map(fn) → list list

New list with the result of calling fn on every element; to return an object literal from an arrow function, wrap it in parentheses.

{{ $json.items.map(item => ({ sku: item.sku, subtotal: item.qty * item.price })) }}
Result list
[
  {
    "sku": "SKU-1",
    "subtotal": 91
  },
  {
    "sku": "SKU-2",
    "subtotal": 19.99
  },
  {
    "sku": "SKU-3",
    "subtotal": 120
  }
]
list.pop() → any list

Mutates the list: removes the last element and returns it; use at(-1) to read it without changing the list.

{{ [...$json.items].pop().sku }}
Result string
"SKU-3"
list.push(...values) → number list

Mutates the list: appends the values and returns the new length, not the list; use concat or [...list, value] to get a new list.

{{ [...$json.body.tags].push('priority') }}
Result number
4
list.reduce(fn, initial?) → any list

Folds the list into a single value; always pass initial, because an empty list without it throws TypeError.

{{ $json.items.reduce((total, item) => total + item.qty * item.price, 0) }}
Result number
230.99
list.reduceRight(fn, initial?) → any list

Like reduce, but from the last element to the first.

{{ $json.matrix.reduceRight((acc, row) => acc.concat(row), []) }}
Result list
[3,4,1,2]
list.reverse() → list list

Mutates the list: reverses it in place; use toReversed to get a reversed copy.

{{ [...$json.body.tags].reverse() }}
Result list
["vip","b2b","vip"]
list.shift() → any list

Mutates the list: removes the first element and returns it; use [0] or at(0) to read it without changing the list.

{{ [...$json.items].shift().sku }}
Result string
"SKU-1"
list.slice(start?, end?) → list list

Copy of the part between start and end (exclusive) without mutating; negative indexes count from the end.

{{ $json.items.slice(0, 2) }}
Result list
[
  {
    "sku": "SKU-1",
    "name": "Keyboard",
    "qty": 2,
    "price": 45.5,
    "category": "hardware"
  },
  {
    "sku": "SKU-2",
    "name": "Mouse",
    "qty": 1,
    "price": 19.99,
    "category": "hardware"
  }
]
list.some(predicate) → boolean list

Returns true when predicate is true for at least one element.

{{ $json.items.some(item => item.price > 100) }}
Result boolean
true
list.sort(compare?) → list list

Mutates the list and, without compare, sorts the elements as text (10 comes before 9); pass (a, b) => a - b for numbers and copy first, or use toSorted.

{{ [...$json.items].sort((a, b) => b.price - a.price)[0].sku }}
Result string
"SKU-3"
list.splice(start, deleteCount?, ...items) → list list

Mutates the list: removes deleteCount elements from start, inserts items, and returns the removed elements; use toSpliced to get a copy.

{{ [...$json.items].splice(1, 1)[0].sku }}
Result string
"SKU-2"
list.toLocaleString(locale?, options?) → string list

Joins the elements with commas, formatting each one with its own toLocaleString.

{{ $json.items.map(item => item.price).toLocaleString('es-CO') }}
Result string
"45,5,19,99,120"
list.toReversed() → list list

Reversed copy of the list; does not mutate.

{{ $json.body.tags.toReversed() }}
Result list
["vip","b2b","vip"]
list.toSorted(compare?) → list list

Sorted copy of the list; does not mutate. Without compare it also sorts as text.

{{ $json.items.toSorted((a, b) => a.price - b.price).map(item => item.sku) }}
Result list
["SKU-2","SKU-1","SKU-3"]
list.toSpliced(start, deleteCount?, ...items) → list list

Copy of the list with elements removed or inserted, like splice but without mutating.

{{ $json.items.toSpliced(0, 1).length }}
Result number
2
list.toString() → string list

Joins the elements with commas, the same as join(",").

{{ $json.body.tags.toString() }}
Result string
"vip,b2b,vip"
list.unshift(...values) → number list

Mutates the list: inserts the values at the start and returns the new length; use [value, ...list] to get a new list.

{{ [...$json.body.tags].unshift('new') }}
Result number
4
list.values() → iterator list

Iterator of the elements; spread it with [...] to get a list.

{{ [...$json.body.tags.values()].length }}
Result number
3
list.with(index, value) → list list

Copy of the list with the element at index replaced by value; does not mutate.

{{ $json.body.tags.with(0, 'gold') }}
Result list
["gold","b2b","vip"]

Object

Static functions to inspect, build and transform objects. Functions that freeze or redefine properties mutate their argument, so apply them to a copy ({ ...obj }) rather than to $json.

Object.assign(target, ...sources) → object

Copies the own enumerable properties of sources into target, mutating it, and returns target; pass {} as target to get a new object.

{{ Object.assign({}, $json.customer, { tier: 'gold' }) }}
Result object
{"id":"cus_001","email":"[email protected]","country":"CO","tier":"gold"}
Object.create(prototype, descriptors?) → object

Creates an object with the given prototype; Object.create(null) gives a dictionary with no inherited keys.

{{ Object.assign(Object.create(null), $json.customer).email }}
Result string
Object.defineProperties(target, descriptors) → object

Mutates target: defines several properties from descriptors; they are non-enumerable unless you set enumerable: true.

{{ JSON.stringify(Object.defineProperties({}, { sku: { value: 'SKU-1', enumerable: true } })) }}
Result string
"{\"sku\":\"SKU-1\"}"
Object.defineProperty(target, key, descriptor) → object

Mutates target: defines one property from a descriptor; it is non-enumerable by default, so JSON.stringify and Object.keys skip it.

{{ Object.keys(Object.defineProperty({ ...$json.customer }, 'internal', { value: true })) }}
Result list
["id","email","country"]
Object.entries(value) → list

List of [key, value] pairs of the own enumerable properties.

{{ Object.entries($json.customer).map(([key, value]) => key + '=' + value).join('&') }}
Result string
"id=cus_001&[email protected]&country=CO"
Object.freeze(value) → object

Makes the object shallowly immutable and returns it; it freezes the argument itself, so freeze a copy, never $json.

{{ Object.isFrozen(Object.freeze({ ...$json.customer })) }}
Result boolean
true
Object.fromEntries(entries) → object

Builds an object from a list of [key, value] pairs or a Map; the inverse of Object.entries.

{{ Object.fromEntries($json.items.map(item => [item.sku, item.qty])) }}
Result object
{"SKU-1":2,"SKU-2":1,"SKU-3":1}
Object.getOwnPropertyDescriptor(value, key) → object

Descriptor (value, writable, enumerable, configurable, or get/set) of one own property, or undefined.

{{ Object.getOwnPropertyDescriptor($json.customer, 'email').writable }}
Result boolean
true
Object.getOwnPropertyDescriptors(value) → object

Descriptors of every own property, keyed by property name.

{{ Object.keys(Object.getOwnPropertyDescriptors($json.customer)) }}
Result list
["id","email","country"]
Object.getOwnPropertyNames(value) → list

Names of every own string key, including non-enumerable ones such as length on a list.

{{ Object.getOwnPropertyNames($json.body.tags) }}
Result list
["0","1","2","length"]
Object.getOwnPropertySymbols(value) → list

Own symbol keys; workflow data parsed from JSON never has any.

{{ Object.getOwnPropertySymbols($json.customer).length }}
Result number
0
Object.getPrototypeOf(value) → object

Prototype of the object, or null.

{{ Object.getPrototypeOf($json.customer) === Object.prototype }}
Result boolean
true
Object.groupBy(items, keyFn) → object Node 22

Groups a list into an object whose keys are the results of keyFn and whose values are lists of matching elements.

{{ Object.groupBy($json.items, item => item.category) }}
Result object
{
  "hardware": [
    {
      "sku": "SKU-1",
      "name": "Keyboard",
      "qty": 2,
      "price": 45.5,
      "category": "hardware"
    },
    {
      "sku": "SKU-2",
      "name": "Mouse",
      "qty": 1,
      "price": 19.99,
      "category": "hardware"
    }
  ],
  "services": [
    {
      "sku": "SKU-3",
      "name": "Support plan",
      "qty": 1,
      "price": 120,
      "category": "services"
    }
  ]
}
Object.hasOwn(value, key) → boolean

Returns true when the object has key as its own property (not inherited); safer than in or obj.hasOwnProperty.

{{ Object.hasOwn($json.customer, 'email') }}
Result boolean
true
Object.is(a, b) → boolean

SameValue comparison: like ===, but NaN equals NaN and 0 differs from -0.

{{ Object.is(Number($json.body.qty), 3) }}
Result boolean
true
Object.isExtensible(value) → boolean

Returns true when new properties can be added to the object.

{{ Object.isExtensible($json.customer) }}
Result boolean
true
Object.isFrozen(value) → boolean

Returns true when the object is frozen.

{{ Object.isFrozen($json.customer) }}
Result boolean
false
Object.isSealed(value) → boolean

Returns true when the object is sealed.

{{ Object.isSealed($json.customer) }}
Result boolean
false
Object.keys(value) → list

List of the own enumerable keys.

{{ Object.keys($json.customer) }}
Result list
["id","email","country"]
Object.preventExtensions(value) → object

Mutates the object so no new properties can be added, and returns it.

{{ Object.isExtensible(Object.preventExtensions({ ...$json.customer })) }}
Result boolean
false
Object.seal(value) → object

Mutates the object so properties cannot be added or removed (existing ones stay writable), and returns it.

{{ Object.isSealed(Object.seal({ ...$json.customer })) }}
Result boolean
true
Object.setPrototypeOf(value, prototype) → object

Mutates the object by replacing its prototype; rarely needed in expressions.

{{ Object.getPrototypeOf(Object.setPrototypeOf({ ...$json.customer }, null)) }}
Result null
null
Object.values(value) → list

List of the own enumerable values.

{{ Object.values($json.customer) }}
Result list
["cus_001","[email protected]","CO"]

Boolean

Truthiness conversion. Flags that arrive as text must be compared explicitly, because any non-empty text is truthy.

Boolean(value) → boolean

Converts a value to true or false: "", 0, NaN, null and undefined are false, while any non-empty text, including "false" and "0", is true; compare text flags with === "true".

{{ Boolean($json.customer.email) && $json.body.paid === 'true' }}
Result boolean
true

Date

The native Date object. Prefer Luxon ($now, $today) for parsing, time zones and calendar arithmetic. Date local getters and setters use the server's time zone, not the user's, so use the UTC variants or pass a timeZone when formatting.

new Date(value?) → Date

Creates a date from ISO text, a timestamp in milliseconds or parts; a date-only text ("2026-12-01") is read as UTC midnight, a date-time without offset as server time, and invalid input gives an Invalid Date.

{{ new Date($json.body.created_at).toISOString() }}
Result string
"2026-11-20T14:30:00.000Z"
Date.now() → number

Current time as milliseconds since the Unix epoch.

{{ Date.now() - new Date($json.body.created_at).getTime() }}
Result number
543089959
Date.parse(text) → number

Parses date text and returns its timestamp in milliseconds, or NaN when it cannot be parsed.

{{ Date.parse($json.body.due_date) }}
Result number
1796083200000
Date.UTC(year, monthIndex, day?, hours?, minutes?, seconds?, ms?) → number

Timestamp in milliseconds for a UTC date built from parts; monthIndex starts at 0 (January is 0, December is 11).

{{ new Date(Date.UTC(2026, 11, 31)).toISOString() }}
Result string
"2026-12-31T00:00:00.000Z"
date.getDate() → number date

Day of the month (1–31) in the server's time zone.

{{ new Date($json.body.created_at).getDate() }}
Result number
20
date.getDay() → number date

Day of the week (0 = Sunday to 6 = Saturday) in the server's time zone.

{{ new Date($json.body.created_at).getDay() }}
Result number
5
date.getFullYear() → number date

Four-digit year in the server's time zone.

{{ new Date($json.body.created_at).getFullYear() }}
Result number
2026
date.getHours() → number date

Hour (0–23) in the server's time zone.

{{ new Date($json.body.created_at).getHours() }}
Result number
9
date.getMilliseconds() → number date

Milliseconds (0–999) in the server's time zone.

{{ new Date($json.body.created_at).getMilliseconds() }}
Result number
0
date.getMinutes() → number date

Minutes (0–59) in the server's time zone.

{{ new Date($json.body.created_at).getMinutes() }}
Result number
30
date.getMonth() → number date

Month index (0 = January to 11 = December) in the server's time zone; add 1 for the calendar month.

{{ new Date($json.body.created_at).getMonth() + 1 }}
Result number
11
date.getSeconds() → number date

Seconds (0–59) in the server's time zone.

{{ new Date($json.body.created_at).getSeconds() }}
Result number
0
date.getTime() → number date

Timestamp in milliseconds since the Unix epoch; NaN for an Invalid Date.

{{ new Date($json.body.created_at).getTime() }}
Result number
1795185000000
date.getTimezoneOffset() → number date

Difference in minutes between UTC and the server's time zone, positive west of UTC (300 for UTC−5).

{{ new Date($json.body.created_at).getTimezoneOffset() }}
Result number
300
date.getUTCDate() → number date

Day of the month (1–31) in UTC.

{{ new Date($json.body.created_at).getUTCDate() }}
Result number
20
date.getUTCDay() → number date

Day of the week (0 = Sunday to 6 = Saturday) in UTC.

{{ new Date($json.body.created_at).getUTCDay() }}
Result number
5
date.getUTCFullYear() → number date

Four-digit year in UTC.

{{ new Date($json.body.created_at).getUTCFullYear() }}
Result number
2026
date.getUTCHours() → number date

Hour (0–23) in UTC.

{{ new Date($json.body.created_at).getUTCHours() }}
Result number
14
date.getUTCMilliseconds() → number date

Milliseconds (0–999) in UTC.

{{ new Date($json.body.created_at).getUTCMilliseconds() }}
Result number
0
date.getUTCMinutes() → number date

Minutes (0–59) in UTC.

{{ new Date($json.body.created_at).getUTCMinutes() }}
Result number
30
date.getUTCMonth() → number date

Month index (0 = January to 11 = December) in UTC.

{{ new Date($json.body.created_at).getUTCMonth() + 1 }}
Result number
11
date.getUTCSeconds() → number date

Seconds (0–59) in UTC.

{{ new Date($json.body.created_at).getUTCSeconds() }}
Result number
0
date.setDate(day) → number date

Mutates the date: sets the day of the month in the server's time zone (overflow rolls into the next month) and returns the new timestamp in milliseconds; wrap it in new Date(...) to keep working with a date.

{{ new Date(new Date($json.body.created_at).setDate(new Date($json.body.created_at).getDate() + 30)).toISOString() }}
Result string
"2026-12-20T14:30:00.000Z"
date.setFullYear(year, monthIndex?, day?) → number date

Mutates the date: sets the year in the server's time zone and returns the new timestamp in milliseconds; wrap it in new Date(...) to keep working with a date.

{{ new Date($json.body.created_at).setFullYear(2027) }}
Result number
1826721000000
date.setHours(hours, minutes?, seconds?, ms?) → number date

Mutates the date: sets the time of day in the server's time zone and returns the new timestamp in milliseconds; wrap it in new Date(...) to keep working with a date.

{{ new Date(new Date($json.body.created_at).setHours(0, 0, 0, 0)).getDate() }}
Result number
20
date.setMilliseconds(ms) → number date

Mutates the date: sets the milliseconds in the server's time zone and returns the new timestamp in milliseconds; wrap it in new Date(...) to keep working with a date.

{{ new Date($json.body.created_at).setMilliseconds(0) }}
Result number
1795185000000
date.setMinutes(minutes, seconds?, ms?) → number date

Mutates the date: sets the minutes in the server's time zone and returns the new timestamp in milliseconds; wrap it in new Date(...) to keep working with a date.

{{ new Date($json.body.created_at).setMinutes(0, 0, 0) }}
Result number
1795183200000
date.setMonth(monthIndex, day?) → number date

Mutates the date: sets the month index (0–11) in the server's time zone and returns the new timestamp in milliseconds; wrap it in new Date(...) to keep working with a date.

{{ new Date($json.body.created_at).setMonth(0) }}
Result number
1768919400000
date.setSeconds(seconds, ms?) → number date

Mutates the date: sets the seconds in the server's time zone and returns the new timestamp in milliseconds; wrap it in new Date(...) to keep working with a date.

{{ new Date($json.body.created_at).setSeconds(0, 0) }}
Result number
1795185000000
date.setTime(timestamp) → number date

Mutates the date: sets the whole date from a timestamp in milliseconds and returns the new timestamp in milliseconds; wrap it in new Date(...) to keep working with a date.

{{ new Date(new Date().setTime(Date.parse($json.body.due_date))).toISOString() }}
Result string
"2026-12-01T00:00:00.000Z"
date.setUTCDate(day) → number date

Mutates the date: sets the day of the month in UTC and returns the new timestamp in milliseconds; wrap it in new Date(...) to keep working with a date.

{{ new Date(new Date($json.body.created_at).setUTCDate(new Date($json.body.created_at).getUTCDate() + 30)).toISOString() }}
Result string
"2026-12-20T14:30:00.000Z"
date.setUTCFullYear(year, monthIndex?, day?) → number date

Mutates the date: sets the year in UTC and returns the new timestamp in milliseconds; wrap it in new Date(...) to keep working with a date.

{{ new Date(new Date($json.body.created_at).setUTCFullYear(2027)).toISOString() }}
Result string
"2027-11-20T14:30:00.000Z"
date.setUTCHours(hours, minutes?, seconds?, ms?) → number date

Mutates the date: sets the time of day in UTC and returns the new timestamp in milliseconds; wrap it in new Date(...) to keep working with a date.

{{ new Date(new Date($json.body.created_at).setUTCHours(0, 0, 0, 0)).toISOString() }}
Result string
"2026-11-20T00:00:00.000Z"
date.setUTCMilliseconds(ms) → number date

Mutates the date: sets the milliseconds in UTC and returns the new timestamp in milliseconds; wrap it in new Date(...) to keep working with a date.

{{ new Date($json.body.created_at).setUTCMilliseconds(0) }}
Result number
1795185000000
date.setUTCMinutes(minutes, seconds?, ms?) → number date

Mutates the date: sets the minutes in UTC and returns the new timestamp in milliseconds; wrap it in new Date(...) to keep working with a date.

{{ new Date(new Date($json.body.created_at).setUTCMinutes(0, 0, 0)).toISOString() }}
Result string
"2026-11-20T14:00:00.000Z"
date.setUTCMonth(monthIndex, day?) → number date

Mutates the date: sets the month index (0–11) in UTC and returns the new timestamp in milliseconds; wrap it in new Date(...) to keep working with a date.

{{ new Date(new Date($json.body.created_at).setUTCMonth(11, 31)).toISOString() }}
Result string
"2026-12-31T14:30:00.000Z"
date.setUTCSeconds(seconds, ms?) → number date

Mutates the date: sets the seconds in UTC and returns the new timestamp in milliseconds; wrap it in new Date(...) to keep working with a date.

{{ new Date($json.body.created_at).setUTCSeconds(0, 0) }}
Result number
1795185000000
date.toDateString() → string date

Date part as English text in the server's time zone ("Fri Nov 20 2026").

{{ new Date($json.body.created_at).toDateString() }}
Result string
"Fri Nov 20 2026"
date.toISOString() → string date

ISO 8601 text in UTC ("2026-11-20T14:30:00.000Z"); throws RangeError for an Invalid Date.

{{ new Date($json.body.created_at).toISOString() }}
Result string
"2026-11-20T14:30:00.000Z"
date.toJSON() → string date

Same as toISOString, but returns null for an Invalid Date; JSON.stringify calls it.

{{ new Date($json.body.created_at).toJSON() }}
Result string
"2026-11-20T14:30:00.000Z"
date.toLocaleDateString(locale?, options?) → string date

Date part formatted for a locale; pass timeZone in options to avoid the server's zone.

{{ new Date($json.body.created_at).toLocaleDateString('es-CO', { timeZone: 'America/Bogota' }) }}
Result string
"20/11/2026"
date.toLocaleString(locale?, options?) → string date

Date and time formatted for a locale; pass timeZone in options to avoid the server's zone.

{{ new Date($json.body.created_at).toLocaleString('es-CO', { timeZone: 'America/Bogota' }) }}
Result string
"20/11/2026, 9:30:00 a. m."
date.toLocaleTimeString(locale?, options?) → string date

Time part formatted for a locale; pass timeZone in options to avoid the server's zone.

{{ new Date($json.body.created_at).toLocaleTimeString('en-US', { timeZone: 'America/New_York' }) }}
Result string
"9:30:00 AM"
date.toString() → string date

Full English text with the server's time zone; not meant for storage or exchange.

{{ new Date($json.body.created_at).toString() }}
Result string
"Fri Nov 20 2026 09:30:00 GMT-0500 (Colombia Standard Time)"
date.toTimeString() → string date

Time part as text with the server's time zone.

{{ new Date($json.body.created_at).toTimeString() }}
Result string
"09:30:00 GMT-0500 (Colombia Standard Time)"
date.toUTCString() → string date

RFC 7231 text in UTC ("Fri, 20 Nov 2026 14:30:00 GMT"), the format of HTTP headers.

{{ new Date($json.body.created_at).toUTCString() }}
Result string
"Fri, 20 Nov 2026 14:30:00 GMT"

RegExp

Regular expressions, written as literals (/ORD-\d+/i) or built with RegExp. The text methods that take a pattern (match, matchAll, replace, replaceAll, search, split) are listed under String.

new RegExp(pattern, flags?) → RegExp

Builds a regular expression from text, for patterns that include dynamic values; escape special characters that come from data, and double the backslashes inside the text.

{{ new RegExp('^' + $json.customer.country + '-', 'i').test('co-1042') }}
Result boolean
true
regexp.test(text) → boolean regex

Returns true when the text matches; with the g or y flag it advances lastIndex, so repeated calls on the same regex can alternate results.

{{ /^[^@\s]+@[^@\s]+\.[a-z]{2,}$/i.test($json.customer.email) }}
Result boolean
true
regexp.exec(text) → list regex

Returns the first match as a list (full match, then groups) with index and named groups in .groups, or null when nothing matches.

{{ /ORD-(?<number>\d+)/.exec($json.body.order_id).groups.number }}
Result string
"1042"

Map and Set

Keyed collections (Map) and collections of unique values (Set). Both serialize as {}, so convert the result with Object.fromEntries, Array.from or [...] before the expression returns.

new Map(entries?) → Map

Creates a map from [key, value] pairs; keys can be of any type and keep insertion order.

{{ new Map($json.items.map(item => [item.sku, item])).get('SKU-2').price }}
Result number
19.99
Map.groupBy(items, keyFn) → Map Node 22

Groups a list into a Map whose keys are the results of keyFn; unlike Object.groupBy, keys are not converted to text.

{{ Object.fromEntries(Map.groupBy($json.items, item => item.category)) }}
Result object
{
  "hardware": [
    {
      "sku": "SKU-1",
      "name": "Keyboard",
      "qty": 2,
      "price": 45.5,
      "category": "hardware"
    },
    {
      "sku": "SKU-2",
      "name": "Mouse",
      "qty": 1,
      "price": 19.99,
      "category": "hardware"
    }
  ],
  "services": [
    {
      "sku": "SKU-3",
      "name": "Support plan",
      "qty": 1,
      "price": 120,
      "category": "services"
    }
  ]
}
map.get(key) → any map

Value stored under key, or undefined.

{{ new Map(Object.entries($json.customer)).get('country') }}
Result string
"CO"
map.set(key, value) → Map map

Mutates the map: stores value under key and returns the map, so calls can be chained.

{{ new Map().set('total', $json.items.length).get('total') }}
Result number
3
map.has(key) → boolean map

Returns true when the map contains key.

{{ new Map($json.items.map(item => [item.sku, item.qty])).has('SKU-3') }}
Result boolean
true
map.delete(key) → boolean map

Mutates the map: removes key and returns true if it existed.

{{ new Map(Object.entries($json.customer)).delete('id') }}
Result boolean
true
map.clear() → undefined map

Mutates the map: removes every entry.

{{ new Map(Object.entries($json.customer)).clear() }}
Result undefined
undefined
map.size → number map

Number of entries in the map.

{{ new Map($json.items.map(item => [item.category, item])).size }}
Result number
2
map.keys() → iterator map

Iterator of the keys in insertion order; spread it with [...].

{{ [...new Map($json.items.map(item => [item.category, item])).keys()] }}
Result list
["hardware","services"]
map.values() → iterator map

Iterator of the values in insertion order; spread it with [...].

{{ [...new Map($json.items.map(item => [item.sku, item.price])).values()] }}
Result list
[45.5,19.99,120]
map.entries() → iterator map

Iterator of [key, value] pairs; pass it to Object.fromEntries to get an object.

{{ Object.fromEntries(new Map(Object.entries($json.customer)).entries()) }}
Result object
{"id":"cus_001","email":"[email protected]","country":"CO"}
map.forEach(fn) → undefined map

Runs fn(value, key) for each entry and returns undefined.

{{ (() => { const parts = []; new Map(Object.entries($json.customer)).forEach((value, key) => parts.push(key + ':' + value)); return parts.join(';'); })() }}
Result string
"id:cus_001;email:[email protected];country:CO"
new Set(values?) → Set

Creates a set of unique values (objects are compared by reference); spread it with [...] to deduplicate a list.

{{ [...new Set($json.body.tags)] }}
Result list
["vip","b2b"]
set.add(value) → Set set

Mutates the set: adds value and returns the set, so calls can be chained.

{{ new Set($json.body.tags).add('priority').size }}
Result number
3
set.has(value) → boolean set

Returns true when the set contains value; faster than includes on large lists.

{{ new Set($json.body.tags).has('vip') }}
Result boolean
true
set.delete(value) → boolean set

Mutates the set: removes value and returns true if it existed.

{{ new Set($json.body.tags).delete('b2b') }}
Result boolean
true
set.clear() → undefined set

Mutates the set: removes every value.

{{ new Set($json.body.tags).clear() }}
Result undefined
undefined
set.size → number set

Number of unique values in the set.

{{ new Set($json.items.map(item => item.category)).size }}
Result number
2
set.values() → iterator set

Iterator of the values in insertion order; spread it with [...].

{{ [...new Set($json.body.tags).values()] }}
Result list
["vip","b2b"]
set.keys() → iterator set

Same as values(); it exists for symmetry with Map.

{{ [...new Set($json.body.tags).keys()] }}
Result list
["vip","b2b"]
set.entries() → iterator set

Iterator of [value, value] pairs, for symmetry with Map.

{{ [...new Set($json.body.tags).entries()].length }}
Result number
2
set.forEach(fn) → undefined set

Runs fn(value) for each value and returns undefined.

{{ (() => { const upper = []; new Set($json.body.tags).forEach(tag => upper.push(tag.toUpperCase())); return upper; })() }}
Result list
["VIP","B2B"]
set.union(other) → Set set Node 22

New set with the values of both sets.

{{ [...new Set($json.body.tags).union(new Set(['priority']))] }}
Result list
["vip","b2b","priority"]
set.intersection(other) → Set set Node 22

New set with the values present in both sets.

{{ [...new Set($json.body.tags).intersection(new Set(['vip', 'retail']))] }}
Result list
["vip"]
set.difference(other) → Set set Node 22

New set with the values of this set that are not in other.

{{ [...new Set($json.body.tags).difference(new Set(['vip']))] }}
Result list
["b2b"]
set.symmetricDifference(other) → Set set Node 22

New set with the values that are in exactly one of the two sets.

{{ [...new Set($json.body.tags).symmetricDifference(new Set(['vip', 'retail']))] }}
Result list
["b2b","retail"]
set.isSubsetOf(other) → boolean set Node 22

Returns true when every value of this set is in other.

{{ new Set($json.body.tags).isSubsetOf(new Set(['vip', 'b2b', 'retail'])) }}
Result boolean
true
set.isSupersetOf(other) → boolean set Node 22

Returns true when every value of other is in this set.

{{ new Set($json.body.tags).isSupersetOf(new Set(['vip'])) }}
Result boolean
true
set.isDisjointFrom(other) → boolean set Node 22

Returns true when the two sets have no values in common.

{{ new Set($json.body.tags).isDisjointFrom(new Set(['blocked'])) }}
Result boolean
true

Intl

Locale-aware formatting with full ICU data, so every locale and time zone is available. Always pass the locale, and for dates the timeZone, because the defaults are the server's.

new Intl.NumberFormat(locale?, options?).format(value) → string

Formats numbers, currencies (style: "currency", currency), percentages (style: "percent") and units for a locale.

{{ new Intl.NumberFormat('es-CO', { style: 'currency', currency: 'COP' }).format($json.body.amount) }}
Result string
"$ 1.234,57"
new Intl.DateTimeFormat(locale?, options?).format(date) → string

Formats a Date for a locale (dateStyle, timeStyle or individual fields); pass timeZone, otherwise the server's zone is used.

{{ new Intl.DateTimeFormat('es-CO', { dateStyle: 'long', timeZone: 'America/Bogota' }).format(new Date($json.body.created_at)) }}
Result string
"20 de noviembre de 2026"
new Intl.RelativeTimeFormat(locale?, options?).format(value, unit) → string

Formats a relative time such as "in 3 days" or "2 hours ago"; with numeric: "auto" it uses words like "yesterday".

{{ new Intl.RelativeTimeFormat('es', { numeric: 'auto' }).format(-$json.body.retries, 'day') }}
Result string
"anteayer"
new Intl.ListFormat(locale?, options?).format(list) → string

Joins a list of texts with the locale's conjunction ("a, b y c") or disjunction (type: "disjunction").

{{ new Intl.ListFormat('es', { type: 'conjunction' }).format($json.items.map(item => item.name)) }}
Result string
"Keyboard, Mouse y Support plan"
new Intl.PluralRules(locale?, options?).select(count) → string

Returns the plural category of a number for a locale ("one", "other", …), to pick the right word form.

{{ new Intl.PluralRules('en-US').select($json.items.length) === 'one' ? 'item' : 'items' }}
Result string
"items"
new Intl.Collator(locale?, options?).compare → function

Locale-aware comparison function for sort; sensitivity: "base" ignores case and accents.

{{ $json.items.map(item => item.name).sort(new Intl.Collator('es', { sensitivity: 'base' }).compare) }}
Result list
["Keyboard","Mouse","Support plan"]

Not available

Name Instead
require There is no module system. Use the built-ins on this page, lodash as _, or a Code node (code.js) for logic that needs more.
process Not defined. Pass the values you need from the trigger or a previous node and read them from $json.
Buffer Not defined. Use $base64Encode / $base64Decode for Base64, and a Code node for binary data.
atob Not defined. Use $base64Decode(text).
btoa Not defined. Use $base64Encode(text).
setTimeout Not defined: expressions are synchronous and limited to 100 ms. Use a flow.wait node to pause a workflow.
setInterval Not defined. For repeated runs use a cron.trigger trigger; for retries, the node's retry settings.
fetch Not defined: expressions cannot make network calls. Use an io.http node and read its output in the next node.
structuredClone Not defined. Use _.cloneDeep(value), or JSON.parse(JSON.stringify(value)) for plain JSON data.
URL Not defined. Build URLs with encodeURIComponent and read their parts with split or a regular expression.
URLSearchParams Not defined. Use $toQueryString(object) to build a query string, or Object.entries with encodeURIComponent.
TextEncoder Not defined. Text is handled as JavaScript strings; use a Code node when you need UTF-8 bytes.
TextDecoder Not defined. Decode bytes in a Code node, or use $base64Decode for Base64 text.
crypto Not defined. Use $uuid for unique identifiers.
async / await Expressions are synchronous: await is a syntax error and an async function returns a Promise that is never awaited (it becomes {} in text). Do asynchronous work in a node.
console.log Accepted but discarded, and console.error / console.warn do not exist. To inspect a value, return it from the expression and check the node's output in the run.

Example context

The examples of this page run over this input as $json. They do not change it: each example runs in a fresh context.

JSON
{
  "$json": {
    "body": {
      "email": " [email protected] ",
      "name": "ana pérez",
      "order_id": "ORD-1042",
      "created_at": "2026-11-20T14:30:00Z",
      "due_date": "2026-12-01",
      "total": "1234.5",
      "amount": 1234.567,
      "qty": "3",
      "discount": 0.15,
      "status": "paid",
      "phone": "+57 300 123 4567",
      "tags": [
        "vip",
        "b2b",
        "vip"
      ],
      "key": "a b&c",
      "url": "https://example.com/orders?id=ORD-1042&page=2",
      "query": "name=Ana%20P%C3%A9rez",
      "payload": "{\"sku\":\"SKU-1\",\"qty\":2}",
      "note": "Line 1\nLine 2",
      "code": "abc-123",
      "score": 0.8734,
      "lat": 4.711,
      "lon": -74.0721,
      "count": 42,
      "radius": 2,
      "paid": "true",
      "retries": 2
    },
    "items": [
      {
        "sku": "SKU-1",
        "name": "Keyboard",
        "qty": 2,
        "price": 45.5,
        "category": "hardware"
      },
      {
        "sku": "SKU-2",
        "name": "Mouse",
        "qty": 1,
        "price": 19.99,
        "category": "hardware"
      },
      {
        "sku": "SKU-3",
        "name": "Support plan",
        "qty": 1,
        "price": 120,
        "category": "services"
      }
    ],
    "customer": {
      "id": "cus_001",
      "email": "[email protected]",
      "country": "CO"
    },
    "matrix": [
      [
        1,
        2
      ],
      [
        3,
        4
      ]
    ]
  }
}

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