Pipeline Functions

Pipeline functions process a value inside an expression. You can remove extra spaces from text, sort a list, read an Object field, or format a date before using it in another Block.

Start with Template Syntax if you are new to expressions, or see Use Variables for help inserting a pipeline function in the editor.

Apply a Pipeline Function

Write | after a value, followed by the function name:

{{ $vars.name | trim }}

If name holds Tapicker , the result is Tapicker. The value on the left is passed to the function automatically.

Chain functions to process the result from left to right:

{{ $vars.name | trim | toUpper }}

This removes surrounding spaces, then converts the text to uppercase. The result is TAPICKER.

If a function needs additional arguments, put them in parentheses. Arguments can be literals, variables, or calculations:

{{ $vars.items | join(', ') }}
{{ $vars.title | replace($vars.searchText, $vars.replacement) }}

Parentheses are optional when there are no additional arguments: trim and trim() mean the same thing. In the reference below, ? marks an optional argument, = ... shows a default, and ...items means you can supply several items separated by commas. These marks describe the arguments; do not type them when calling a function.

To calculate values, use expression operators, such as {{ $vars.price * $vars.quantity }}. To get or generate a value, use a Helper Function, such as getDate().

Available Function Groups

Functions are organized into eight groups:

  • String — clean, split, and format text.
  • Array — select, sort, group, and combine items.
  • Object — read and organize named fields.
  • Number — round, format, and limit numbers.
  • Date — format dates and calculate time differences.
  • Encoding — encode text, decode data, and convert image URLs.
  • RegExp — test text against a pattern.
  • General — provide fallbacks, choose values, and convert types.

Many String, Number, Date, Encoding, and conversion functions also process Array items individually. For example, {{ [' a ', ' b '] | trim }} returns ["a", "b"].

Functions work with the underlying data in Duck values, preserving source or item targets where applicable. A field that produces ordinary text or JSON uses the underlying data in its output.

Most functions return a result without changing their input. Exceptions such as drop, set, and sample in 'drop' mode are noted below. Use copy before those functions when you need to keep the original data.

For transformations configured through the editor instead of written in expressions, see Data Transformation.

String

Use these functions to process text. They also work on each item when the input is an Array. slice is an exception: it selects a portion of the Array itself.

trim(position = 'both')

Removes whitespace from both ends of text by default. Use 'start' or 'end' to trim only one end.

{{ '  Tapicker  ' | trim }}

Returns Tapicker.

split(separator = '')

Splits text into an Array at each separator. With the default empty separator, it splits into individual characters.

{{ 'red,green,blue' | split(',') }}

Returns ["red", "green", "blue"].

replace(search, replacement = '')

Replaces matching text. search can be a String or a regular expression. A String replaces only the first occurrence; use a regular expression with the g flag to replace all matches. Omitting replacement removes the matched text.

{{ 'red red' | replace('red', 'blue') }}

Returns blue red.

{{ 'red red' | replace(/red/g, 'blue') }}

Returns blue blue. See Regular Expressions for help writing a pattern.

extract(regexp, separator = ', ')

Finds matches in text and joins them into a String. Returns an empty String when nothing matches.

{{ 'Items: 12 and 34' | extract(/\d+/g, ' | ') }}

Returns 12 | 34. Use g to collect all matches. Without g, the result includes the first full match and any captured groups, as with match below.

match(regexp)

Returns an Array of matches, or null if nothing matches. With g, it returns all full matches. Without g, it returns the first full match followed by any captured groups.

{{ 'Items: 12 and 34' | match(/\d+/g) }}

Returns ["12", "34"].

{{ 'Order #123' | match(/#(\d+)/) }}

Returns ["#123", "123"]. Choose match when you need a list; choose extract when you need joined text.

truncate(length, suffix = '…')

Keeps the first length characters and appends a suffix if the text is longer. The suffix is added after the retained text, so the final result can exceed length.

{{ 'Tapicker' | truncate(3) }}

Returns Tap…. Use truncate(3, '') to return just Tap.

slice(start, end)

Returns part of a String or Array, including start and excluding end. Positions start at 0. Omit end to keep everything from start onward; negative positions count from the end.

{{ 'Tapicker' | slice(0, 3) }}
{{ [10, 20, 30, 40] | slice(1, 3) }}

The results are Tap and [20, 30], respectively.

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

Adds text before and after the input. The arguments are independent: supplying only a prefix does not add a matching suffix.

{{ 'Tapicker' | wrap('[', ']') }}

Returns [Tapicker]. Using wrap('[') returns [Tapicker; using wrap('', ']') returns Tapicker].

pad(position, length, char = ' ')

Adds fill characters until the text reaches the requested length. position can be 'start', 'end', or 'both'. Text that already meets the length is kept.

{{ '42' | pad('start', 5, '0') }}

Returns 00042. Use a single fill character for predictable lengths with 'both'.

toUpper()

Converts text to uppercase.

{{ 'Tapicker' | toUpper }}

Returns TAPICKER.

toLower()

Converts text to lowercase.

{{ 'Tapicker' | toLower }}

Returns tapicker.

Array

Use these functions to work with lists. Many also accept Strings as character sequences; the examples below show where the result differs.

at(index?)

Reads an item without removing it. Positions start at 0; negative positions count from the end. Omit index to choose a random item. An empty input or out-of-range position returns undefined.

{{ ['red', 'green', 'blue'] | at(0) }}
{{ ['red', 'green', 'blue'] | at(-1) }}

The results are red and blue. For a String, {{ 'abc' | at(1) }} returns b.

drop(index?)

Removes an item from the input Array and returns the removed item, rather than the remaining Array. Omit index to remove a random item. Use a zero-based, non-negative integer index; an empty input or out-of-range position returns undefined.

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

If items is ["red", "green", "blue"], the result is red, and the original Array becomes ["green", "blue"]. Use at(0) if you only want to read the item.

For a String, it returns the selected character without changing the original String.

join(separator = ', ')

Combines Array items into one String. A String input is treated as a sequence of characters.

{{ ['red', 'green', 'blue'] | join(', ') }}

Returns red, green, blue. Using {{ 'abc' | join('-') }} returns a-b-c.

prepend(...items)

Adds one or more items to the beginning of an Array and returns a new Array. For a String, it adds text at the beginning.

{{ ['green', 'blue'] | prepend('red') }}
{{ 'Tapicker' | prepend('Hello, ') }}

The results are ["red", "green", "blue"] and Hello, Tapicker.

append(...items)

Adds one or more items to the end of an Array and returns a new Array. For a String, it adds text at the end.

{{ ['red', 'green'] | append('blue') }}
{{ 'Tapicker' | append('!') }}

The results are ["red", "green", "blue"] and Tapicker!. An Array passed as an argument is added as one item; use concat to combine lists.

concat(...arrays)

Combines Arrays into a new Array, preserving their order.

{{ [1, 2] | concat([3, 4], [5]) }}

Returns [1, 2, 3, 4, 5].

size()

Returns the number of Array items or the length of a String. Use this function instead of .length in Template Syntax.

{{ ['red', 'green', 'blue'] | size }}
{{ 'Tapicker' | size }}

The results are 3 and 8.

sort()

Returns a sorted copy using a natural, case-insensitive comparison. Numbers within text are compared numerically.

{{ ['item10', 'item2', 'item1'] | sort }}

Returns ["item1", "item2", "item10"]. Use sort | reverse for descending order. A String input returns a sorted String.

sortBy(path)

Returns Array items sorted by the value at a field path, using the same comparison as sort. Use dots for nested fields.

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

This sorts users by age in ascending order. Add | reverse for descending order. The Object section explains field paths.

unique()

Removes duplicate values, keeping the first occurrence and preserving the remaining order. Object values are compared by their JSON representation.

{{ ['red', 'red', 'blue'] | unique }}

Returns ["red", "blue"]. A String input such as 'abca' returns abc.

uniqueBy(path)

Removes items with duplicate values at the given field path. The first item for each value is kept.

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

This keeps one product for each id. Items missing that field share the same undefined key, so only the first of them is kept.

compact()

Removes null, undefined, and empty Strings. It keeps 0, false, and Strings containing only spaces.

{{ ['red', '', null, 0, false] | compact }}

Returns ["red", 0, false].

compactBy(path)

Removes Array items whose value at the given field path is null, undefined, or an empty String.

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

This keeps users with a non-empty profile.name. It uses the same empty-value rules as compact.

shuffle()

Returns the items in a random order without changing the original Array. A String input returns its characters in a random order.

{{ $vars.items | shuffle }}

The order can change each time the expression is evaluated.

reverse()

Returns a reversed copy of an Array or String.

{{ [1, 2, 3] | reverse }}
{{ 'abc' | reverse }}

The results are [3, 2, 1] and cba.

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

Selects up to count random items without selecting the same position twice. It returns the selected items, not the items left over. Supply a non-negative integer count; the default of 0 returns an empty result.

  • 'keep' leaves the input Array unchanged.
  • 'drop' removes selected items from the input Array.
{{ $vars.items | sample(2) }}
{{ $vars.items | sample(2, 'drop') }}

If items is ["red", "green", "blue"], either call could return ["blue", "red"]. The second call also leaves ["green"] in the input Array. If fewer than two items are available, it returns all available items.

A String input returns selected characters as a String and leaves the original String unchanged in either mode.

chunk(size = 3)

Splits a list into an Array of smaller Arrays. Use a positive integer size. The last chunk may contain fewer items.

{{ [1, 2, 3, 4, 5] | chunk(2) }}

Returns [[1, 2], [3, 4], [5]]. For a String, {{ 'abcde' | chunk(2) }} returns ["ab", "cd", "e"].

groupBy(path)

Groups Array items by a field value and returns an Object. Each key identifies a group, and its value is an Array of matching items.

{{ $vars.products | groupBy('category') }}

Products with the same category appear in the same group. Group keys are converted to text.

flatten(depth = 1)

Removes layers of nested Arrays up to the specified depth.

{{ [1, [2, [3]]] | flatten }}
{{ [1, [2, [3]]] | flatten(2) }}

The results are [1, 2, [3]] and [1, 2, 3].

Object

Use these functions to work with named fields. Functions that accept a path support dot-separated fields, such as 'profile.name', or an Array of path segments, such as ['profile', 'name'].

For Array positions inside a path, use 'items.0.name' or ['items', 0, 'name']. A path String is not a template expression: use these forms rather than 'items[0].name'.

get(path, fallback?)

Reads a field at the given path. If the value is undefined, it returns fallback, or undefined when no fallback is supplied. An existing null or empty String is kept.

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

This reads profile.name, falling back to Anonymous if the field is missing. To replace null and empty Strings too, add | default('Anonymous').

set(path, value)

Writes a value at the given path and returns the Object. Missing intermediate fields are created as Objects. This function changes its input Object.

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

This returns a modified copy, leaving user unchanged. Save the result with Set Variables when you want to keep it for later Blocks.

keys()

Returns the Object's own field names as an Array.

{{ { name: 'Ada', age: 30 } | keys }}

Returns ["name", "age"].

values()

Returns the Object's own field values as an Array.

{{ { name: 'Ada', age: 30 } | values }}

Returns ["Ada", 30].

entries()

Returns an Array of [key, value] pairs.

{{ { name: 'Ada', age: 30 } | entries }}

Returns [["name", "Ada"], ["age", 30]].

pick(keys)

Returns an Object containing only the selected top-level fields. For an Array of Objects, it processes each item.

{{ { name: 'Ada', age: 30 } | pick(['name']) }}

Returns {"name":"Ada"}.

omit(keys)

Returns an Object without the selected top-level fields. For an Array of Objects, it processes each item.

{{ { name: 'Ada', age: 30 } | omit(['age']) }}

Returns {"name":"Ada"}.

merge(...objects)

Combines Objects into a new Object. Later values replace earlier values for the same key. The merge is shallow: a nested Object is replaced as a whole, rather than merged field by field.

{{ { name: 'Ada', active: false } | merge({ active: true }) }}

Returns {"name":"Ada","active":true}. With an Array input, merge concatenates the input and supplied values instead.

copy()

Creates an independent, structured copy of a value. Use it before functions that change their input when you need to preserve the original data.

{{ $vars.user | copy }}

You can also use it with Arrays, for example {{ $vars.items | copy | drop(0) }} to remove and return an item from a copy.

Number

These functions process a Number or each item in an Array. Inputs are converted to Numbers before calculation. min and max combine the values into a single result.

abs()

Returns the absolute value, removing a negative sign.

{{ -12 | abs }}

Returns 12.

ceil()

Rounds up to the nearest integer.

{{ 2.3 | ceil }}

Returns 3.

floor()

Rounds down to the nearest integer.

{{ 2.8 | floor }}

Returns 2.

round()

Rounds to the nearest integer. Halfway values round toward positive infinity: 2.5 becomes 3, while -2.5 becomes -2.

{{ 2.6 | round }}

Returns 3.

fixed(digits = 2)

Formats a Number with exactly digits decimal places and returns a String. Use an integer from 0 to 100 for digits.

{{ 12.5 | fixed(2) }}

Returns the text 12.50. This is useful for display; it is no longer a Number.

min(...numbers)

Returns the smallest Number from the input and any additional arguments. An Array input supplies all its items to the comparison.

{{ [4, 2, 8] | min }}
{{ 4 | min(2, 8) }}

Both return 2.

max(...numbers)

Returns the largest Number from the input and any additional arguments. An Array input supplies all its items to the comparison.

{{ [4, 2, 8] | max }}

Returns 8.

clamp(min, max)

Keeps a Number within the inclusive bounds. Values below min become min; values above max become max. Supply the lower bound first.

{{ 120 | clamp(0, 100) }}

Returns 100.

Date

Use these functions with a Date, a parseable date String, or a timestamp in milliseconds. They also process Arrays item by item. Use getDate() to create a Date for the current time.

Date-time Strings without a timezone are interpreted in local time. Use an explicit offset or Z when the input needs to identify the same instant on different computers.

toISOString()

Converts a date to an ISO 8601 String in UTC.

{{ '2026-01-01T08:00:00+08:00' | toISOString }}

Returns 2026-01-01T00:00:00.000Z.

toTimestamp(unit = 'ms')

Converts a date to a Unix timestamp. Use 'ms' for milliseconds or 's' for whole seconds.

{{ '2026-01-01T00:00:00Z' | toTimestamp }}
{{ '2026-01-01T00:00:00Z' | toTimestamp('s') }}

The results are 1767225600000 and 1767225600.

format(template)

Formats a date as text in local time. Common format tokens include YYYY for year, MM for month, DD for day, HH for hour, mm for minute, and ss for second. Capitalization matters: MM and mm mean different things.

{{ '2026-01-02T03:04:05' | format('YYYY/MM/DD HH:mm:ss') }}

Returns 2026/01/02 03:04:05. The formatter uses Day.js format strings; see its format reference for more tokens.

offset(amount, unit)

Moves a date forward or backward and returns a Date. Use a positive amount to add time or a negative amount to subtract it. Common units include 'year', 'month', 'week', 'day', 'hour', 'minute', and 'second'.

{{ '2026-01-02T03:04:05' | offset(1, 'day') | format('YYYY-MM-DD') }}

Returns 2026-01-03. For two hours earlier, use offset(-2, 'hour').

diff(date, unit)

Returns the difference between the input date and date, in the requested unit. The result is an integer, with any fractional part truncated toward zero. It is negative when the input date is earlier.

{{ '2026-01-03' | diff('2026-01-01', 'day') }}

Returns 2. Use units such as 'day', 'hour', or 'minute'.

Encoding

These functions process a value or each Array item. Encoding is useful when inserting data into a URL or transferring it as text.

encode(kind)

Encodes a value using one of three formats:

  • 'url' — encodes text as a URL component, such as a query parameter value.
  • 'json' — serializes the value as JSON text.
  • 'base64' — encodes text as Base64, including support for Unicode text.
{{ 'wireless headphones' | encode('url') }}

Returns wireless%20headphones. Encode a parameter value rather than the whole URL.

{{ { name: 'Ada' } | encode('json') }}

Returns the text {"name":"Ada"}. An Array input is encoded item by item. To include a whole Array as JSON text, insert it into an ordinary text template; see Build Text from Values.

decode(kind)

Decodes text using 'url', 'json', or 'base64'. JSON decoding returns the parsed value, which can be an Object, Array, Number, or another JSON type. Invalid encoded input can cause an error.

{{ 'wireless%20headphones' | decode('url') }}
{{ '{"name":"Ada"}' | decode('json') }}

The results are wireless headphones and the Object {"name":"Ada"}.

toDataURL(context = 'page')

Fetches an image URL and returns a self-contained Data URL, such as text beginning with data:image/png;base64,. An existing Data URL is returned unchanged. Arrays are processed item by item, preserving Duck target information where applicable.

Choose where to make the request:

  • 'page' — the default. Uses the Workflow's current tab, normally in its main frame. When the input is a Duck, its source frame is used when available. This is useful for images that need the page's session. Page requests are still subject to browser cross-origin rules.
  • 'extension' — requests from the Extension context, using its host permissions. This can help when the page cannot fetch an image from another origin.
{{ $vars.imageURL | toDataURL }}
{{ $vars.imageURL | toDataURL('extension') }}

The image data is included in the result, so it can be used without fetching the original URL again. Data URLs use more space than the binary image; keep the URL instead when you do not need to embed the data.

RegExp

Use a regular expression to check whether text has a particular form.

test(regexp)

Returns true when text matches the pattern and false otherwise. An Array input returns an Array of Boolean results, one per item.

{{ 'Ada' | test(/^A/i) }}
{{ ['Ada', 'Ben'] | test(/^A/i) }}

The results are true and [true, false]. The Array result does not mean “all items match.”

General

Use these functions for fallbacks, conditional values, and type conversion. Conversion functions such as toString, toNumber, toBoolean, and toDate process Array items individually. toArray and toObject process the input as a whole.

default(fallback)

Returns fallback when the input is null, undefined, or an empty String. It keeps 0, false, empty Arrays, empty Objects, and Strings containing only spaces.

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

If name is missing or empty, the result is Anonymous. To treat spaces as empty too, use trim | default('Anonymous').

if(yes, no)

Returns yes when the input is truthy, or no otherwise. Values such as false, 0, null, undefined, and an empty String are falsy. Non-empty Strings, including 'false', are truthy.

{{ $vars.isAvailable | if('In stock', 'Sold out') }}

If isAvailable is true, the result is In stock. Both arguments are evaluated before the function runs; use a conditional expression such as {{ $vars.isAvailable ? 'In stock' : 'Sold out' }} when only the chosen expression should be evaluated.

toString()

Converts a value to text. Objects become JSON text, Dates become ISO text, and null or undefined become an empty String. Array inputs remain Arrays, with each item converted individually.

{{ 42 | toString }}
{{ [1, 2] | toString }}

The results are the text 42 and ["1", "2"]. To combine Array items into one String, use join.

toNumber()

Converts a value to a Number using JavaScript's numeric conversion. Numeric text becomes a Number, empty or whitespace-only text and null become 0, and text that is not numeric produces NaN.

{{ '42' | toNumber }}
{{ ['1', '2'] | toNumber }}

The results are 42 and [1, 2]. Currency text such as '$29.99' needs to be cleaned before conversion.

toBoolean()

Converts a value using JavaScript's truthiness rules. Non-empty Strings are true, including 'false' and '0'; an empty String, 0, null, and undefined are false.

{{ 'false' | toBoolean }}
{{ '' | toBoolean }}

The results are true and false. To interpret text as a specific label, compare it instead, for example {{ $vars.status === 'true' }}. This pipeline function differs from Set Variables' Boolean conversion, which recognizes the text 'true' and 'false'.

toArray()

Returns an Array input as an Array, or parses JSON text containing an Array. Invalid input, including JSON containing another type, returns []. It does not split comma-separated or multiline text; use split for that.

{{ '[1, 2, 3]' | toArray }}

Returns [1, 2, 3].

toObject()

Returns an Object input, or parses JSON text containing an Object. Arrays and invalid input return {}.

{{ '{"name":"Ada"}' | toObject }}

Returns the Object {"name":"Ada"}.

toDate()

Converts a Date, a parseable date String, or a timestamp in milliseconds to a Date value. An unparseable String produces an invalid Date, so check your input before formatting or converting it further.

{{ '2026-01-01T00:00:00Z' | toDate | toISOString }}

Returns 2026-01-01T00:00:00.000Z. See Data Types for more about Date values.