Pipeline Functions

Pipeline functions process the value on their left. They are called with the | operator and can be chained together.

Pipeline functions are different from Data Transformation: pipeline functions are written inside Template Syntax, while transformations are configured in the editor and applied to workflow data.

Pipeline functions operate on Duck payloads while preserving the source or item target metadata where applicable. Text and JSON output modes unwrap Duck values when serializing the final result.

Usage

{{ $vars.name | trim | toUpper }}
{{ $vars.items | sort | join(', ') }}
{{ $vars.date | toDate | format('YYYY-MM-DD') }}

The value on the left is passed to the pipeline function as its first argument. Parentheses can be omitted when a function has no arguments:

{{ $vars.name | trim }}
{{ $vars.name | trim() }}

Arguments are complete template expressions:

{{ $vars.title | replace($vars.pattern, $vars.replacement) }}
{{ $vars.users | sortBy('profile.age') | at(0) }}

Arithmetic should use Template expression operators instead of compatibility pipeline functions:

{{ $vars.a + $vars.b }}
{{ ($vars.price * $vars.quantity) % 100 }}

Legacy compatibility functions are intentionally omitted from this reference and should not be used in new workflows.

String

These functions process string values. See the Array section for sequence functions that also accept strings.

trim(position = 'both')

Removes whitespace from the start, end, or both sides of a string. position can be start, end, or both.

{{ $vars.name | trim }}
{{ $vars.name | trim('start') }}

split(separator = '')

Splits a string into an array.

{{ $vars.csv | split(',') }}

replace(search, replacement = '')

Replaces text or regular-expression matches.

{{ $vars.name | replace(' ', '-') }}
{{ $vars.text | replace(/\s+/g, ' ') }}

extract(regexp, separator = ', ')

Extracts matched parts and joins them into a string.

{{ $vars.text | extract(/\d+/g) }}
{{ $vars.text | extract(/\d+/g, ' | ') }}

match(regexp)

Returns the matched parts of a string, or null when there is no match.

{{ $vars.text | match(/\d+/g) }}

truncate(length, suffix = '...')

Limits a string to the specified length and appends a suffix when it is truncated.

{{ $vars.description | truncate(80) }}

slice(start, end)

Returns a portion of an array or string.

{{ $vars.items | slice(0, 3) }}
{{ $vars.name | slice(0, 5) }}

wrap(prefix = '', suffix = '')

Adds the provided prefix and suffix. Each argument is independent; omitting one does not copy the other.

{{ $vars.name | wrap('<', '>') }}
{{ $vars.name | wrap('<') }}
{{ $vars.name | wrap(null, '>') }}

pad(position, length, char = ' ')

Pads a string to the specified length. position can be start, end, or both.

{{ $vars.id | pad('start', 8, '0') }}

toUpper()

Converts strings to uppercase.

{{ $vars.name | toUpper }}

toLower()

Converts strings to lowercase.

{{ $vars.name | toLower }}

Array

These pipeline functions support arrays. Some also support strings and preserve a string result when appropriate.

at(index?)

Returns the item at index. If index is omitted, a random item is returned.

{{ $vars.items | at(0) }}
{{ $vars.items | at(-1) }}

drop(index?)

Removes and returns the item at index. If index is omitted, a random item is selected.

{{ $vars.items | drop(0) }}

join(separator = ', ')

Joins an array or string sequence into a string.

{{ $vars.items | join(', ') }}

prepend(...items)

Prepends items to an array. For a string, it prepends text.

{{ $vars.items | prepend($vars.item) }}
{{ $vars.name | prepend('Hello ') }}

append(...items)

Appends items to an array. For a string, it appends text.

{{ $vars.items | append($vars.item) }}
{{ $vars.name | append('!') }}

concat(...arrays)

Concatenates arrays.

{{ $vars.first | concat($vars.second) }}

size()

Returns the length of a string or the number of elements in an array.

{{ $vars.name | size }}
{{ $vars.items | size }}

sort()

Sorts an array or string sequence using a natural, case-insensitive comparison.

{{ $vars.items | sort }}

sortBy(path)

Sorts array items by the value at path.

{{ $vars.users | sortBy('profile.age') }}

unique()

Removes duplicate values from an array.

{{ $vars.items | unique }}

uniqueBy(path)

Removes duplicate array items using the value at path as the key.

{{ $vars.users | uniqueBy('id') }}

compact()

Removes empty values (null, undefined, and empty strings) from an array.

{{ $vars.items | compact }}

compactBy(path)

Removes array items whose value at path is empty.

{{ $vars.users | compactBy('profile.name') }}

shuffle()

Randomizes the order of an array or string sequence.

{{ $vars.items | shuffle }}

reverse()

Reverses an array or string.

{{ $vars.items | reverse }}

sample(count = 0, mode = 'keep')

Selects a random number of items from an array or string. mode can be keep or drop.

{{ $vars.items | sample(2) }}
{{ $vars.items | sample(2, 'drop') }}

chunk(size = 3)

Splits an array or string sequence into chunks.

{{ $vars.items | chunk(3) }}

groupBy(path)

Groups array items by the value at path and returns an object.

{{ $vars.users | groupBy('profile.department') }}

flatten(depth = 1)

Flattens nested arrays to the specified depth.

{{ $vars.items | flatten(2) }}

Object

get(path, fallback?)

Reads a value at path. The optional fallback is returned when the path does not exist.

{{ $vars.user | get('profile.name') }}
{{ $vars.user | get('profile.name', 'Anonymous') }}

set(path, value)

Sets a value at path and returns the source object.

{{ $vars.user | set('profile.active', true) }}

keys()

Returns the object's own property names.

{{ $vars.user | keys }}

values()

Returns the object's own property values.

{{ $vars.user | values }}

entries()

Returns the object's key-value entries.

{{ $vars.user | entries }}

pick(keys)

Returns an object containing only the selected keys. Arrays are processed item by item.

{{ $vars.user | pick(['name', 'email']) }}

omit(keys)

Returns an object without the selected keys. Arrays are processed item by item.

{{ $vars.user | omit(['password']) }}

merge(...objects)

Merges objects or concatenates arrays.

{{ $vars.defaults | merge($vars.overrides) }}

copy()

Creates a structured copy of the value.

{{ $vars.user | copy }}

Number

abs()

Returns the absolute value.

{{ $vars.amount | abs }}

ceil()

Rounds up to the nearest integer.

{{ $vars.amount | ceil }}

floor()

Rounds down to the nearest integer.

{{ $vars.amount | floor }}

round()

Rounds to the nearest integer.

{{ $vars.amount | round }}

fixed(digits = 2)

Formats a number with a fixed number of decimal places and returns a string.

{{ $vars.amount | fixed(2) }}

min(...numbers)

Returns the smallest number from the source and arguments. An array source is treated as a list of numbers.

{{ $vars.values | min(0) }}

max(...numbers)

Returns the largest number from the source and arguments.

{{ $vars.values | max(100) }}

clamp(min, max)

Limits a number to the inclusive range from min to max.

{{ $vars.score | clamp(0, 100) }}

Date

toISOString()

Converts a date value to an ISO 8601 string.

{{ $vars.date | toISOString }}

toTimestamp(unit = 'ms')

Converts a date value to a timestamp. Use s for seconds or ms for milliseconds.

{{ $vars.date | toTimestamp }}
{{ $vars.date | toTimestamp('s') }}

format(template)

Formats a date using a Day.js format string.

{{ $vars.date | format('YYYY-MM-DD HH:mm:ss') }}

offset(amount, unit)

Adds or subtracts a date amount. Negative amounts move the date backwards.

{{ $vars.date | offset(1, 'day') }}
{{ $vars.date | offset(-2, 'hour') }}

diff(date, unit)

Returns the difference between the source date and another date in the specified unit.

{{ $vars.date | diff('2026-01-01', 'day') }}

Encoding

encode(kind)

Encodes a value as url, json, or base64.

{{ $vars.keyword | encode('url') }}
{{ $vars.value | encode('json') }}

decode(kind)

Decodes a value encoded as url, json, or base64.

{{ $vars.keyword | decode('url') }}
{{ $vars.value | decode('json') }}

toDataURL(context = 'page')

Downloads an image URL and converts it to a self-contained Data URL. A value that is already a Data URL is returned unchanged. The filter also processes array items and keeps their Duck metadata.

With the default page context, the request runs in the target tab's main frame, or in the source Duck's frame when the value came from an element. This is useful when the image requires the page's cookies or session.

Use extension to make the request from the Extension context instead. This uses the Extension's host permissions and credentials, and can be useful when the page blocks cross-origin requests.

{{ $vars.imageURL | toDataURL }}
{{ $vars.imageURL | toDataURL('extension') }}
{{ $vars.imageURLs | toDataURL }}

Data URLs are convenient for displaying or transferring images without requesting the original server URL again, but they are larger than the original binary resource. Avoid converting very large images when a URL or a separately managed cache is sufficient.

RegExp

test(regexp)

Tests whether a string or every item in an array matches a regular expression.

{{ $vars.name | test(/^A/i) }}

General

default(fallback)

Returns fallback when the input is null, undefined, or an empty string.

{{ $vars.name | default('Anonymous') }}

if(yes, no)

Returns yes when the input is truthy; otherwise returns no.

{{ $vars.enabled | if('enabled', 'disabled') }}

toString()

Converts values to text. Plain objects are serialized as JSON and dates use ISO text. Array inputs are processed item by item and remain arrays.

{{ $vars.user | toString }}

toNumber()

Converts a value to a number.

{{ $vars.count | toNumber }}

toBoolean()

Converts a value to a boolean.

{{ $vars.enabled | toBoolean }}

toArray()

Converts an array value or a JSON array string to an array. Invalid input produces an empty array.

{{ $vars.items | toArray }}
{{ $vars.jsonText | toArray }}

toObject()

Converts an object value or a JSON object string to a plain object. Invalid input produces an empty object.

{{ $vars.user | toObject }}
{{ $vars.jsonText | toObject }}

toDate()

Converts a value to a Date object.

{{ $vars.dateText | toDate }}