Skip to main content

Expression functions

Every function TaskJuice adds to JSONata expressions, for dates and time zones, text, checks, lists, hashing and links, with a working example for each.

What these are

Expressions are JSONata, which comes with its own functions such as $uppercase and $sum. TaskJuice adds the functions below on top. You use them the same way, in any expression field, and they work the same in the editor preview, a node test and a live run.

"Your invoice is due " & $formatDate($addTime($trigger.created, 30, "days"), "MMMM d, yyyy", "America/New_York")

Type $ in an expression field to see them in the autocomplete under Functions. If you misspell one, the editor underlines it and offers the fix.

Dates and times

Dates go in as ISO 8601 text (2026-10-04T09:30:00Z), most other date text, or a timestamp in milliseconds, and come out as ISO 8601. A date and time with no offset (2026-10-04 09:30) is read in the time zone you pass, or UTC. Time zones are names like America/New_York. Formats use the tokens below.

FunctionWhat it doesExampleResult
$formatDate(date, format, timeZone?)Formats a date as text with tokens like yyyy-MM-dd or MMM d, h:mm a, in a time zone (UTC by default).$formatDate("2026-03-08T12:00:00Z", "MMM d, yyyy h:mm a", "America/Los_Angeles")"Mar 8, 2026 5:00 AM"
$parseDate(text, format?, timeZone?)Reads text as a date, using a format when you give one, and returns it as an ISO 8601 date.$parseDate("10/04/2026", "MM/dd/yyyy")"2026-10-04T00:00:00.000Z"
$addTime(date, amount, unit, timeZone?)Adds years, months, weeks, days, hours, minutes or seconds to a date, keeping daylight saving correct in a time zone.$addTime("2026-01-31T10:00:00Z", 1, "month")"2026-02-28T10:00:00.000Z"
$subtractTime(date, amount, unit, timeZone?)Subtracts years, months, weeks, days, hours, minutes or seconds from a date.$subtractTime("2026-10-04T10:00:00Z", 2, "hours")"2026-10-04T08:00:00.000Z"
$startOf(date, unit, timeZone?)The first moment of the year, quarter, month, week (from Monday), day, hour or minute a date falls in.$startOf("2026-10-04T15:30:00Z", "month")"2026-10-01T00:00:00.000Z"
$endOf(date, unit, timeZone?)The last moment of the year, quarter, month, week, day, hour or minute a date falls in.$endOf("2026-10-04T15:30:00Z", "month")"2026-10-31T23:59:59.999Z"
$dateDiff(start, end, unit, timeZone?)How many whole units lie between two dates (end minus start), negative when the end comes first.$dateDiff("2026-10-01", "2026-10-04", "days")3
$convertTimezone(date, toTimeZone, fromTimeZone?)Shows a date in another time zone. A date with no offset is read in fromTimeZone (UTC by default).$convertTimezone("2026-10-04T15:30:00Z", "Asia/Tokyo")"2026-10-05T00:30:00.000+09:00"
$today(timeZone?)Midnight at the start of today, in a time zone (UTC by default).$today()a new value each time

Date format tokens

TokenShowsExample
yyyy / yyYear2026 / 26
MMMM / MMM / MM / MMonthOctober / Oct / 10 / 10
dd / dDay of the month04 / 4
EEEE / EEEDay of the weekSunday / Sun
HH / HHour, 24-hour clock09 / 9
hh / hHour, 12-hour clock09 / 9
mmMinutes05
ssSeconds07
aAM or PMPM
xxxOffset from UTC-04:00

Put literal text in single quotes: $formatDate($now(), "'Week' w 'of' yyyy"). Make and Moment use YYYY and DD. Here those letters mean something else, so the function stops with a message telling you to use yyyy and dd.

Checks

Each returns true or false, so they slot straight into a condition or a ternary (cond ? a : b).

FunctionWhat it doesExampleResult
$isEmpty(value)True for a missing value, null, blank text, an empty list or an empty object. 0 and false are not empty.$isEmpty(" ")true
$isNotEmpty(value)The opposite of $isEmpty.$isNotEmpty("hello")true
$ifEmpty(value, fallback)The value, or the fallback when the value is empty (see $isEmpty).$ifEmpty("", "No name")"No name"
$isEmail(text)True when the text is an email address.$isEmail("ada@example.com")true
$isUrl(text)True when the text is a full http or https web address.$isUrl("https://taskjuice.ai/docs")true
$isNumber(value)True for a number, or text that is exactly a number.$isNumber("42.5")true
$toBoolean(value)Turns a value into true or false; "false", "no", "off", "0" and blank text are false (unlike $boolean, which calls any text true).$toBoolean("false")false

Text

A missing value passes through as missing, like JSONata's own text functions.

FunctionWhat it doesExampleResult
$extractEmail(text)The first email address in the text; missing when there is none.$extractEmail("Contact Ada at ada@example.com today")"ada@example.com"
$extractUrl(text)The first http or https link in the text; missing when there is none.$extractUrl("Docs: https://taskjuice.ai/docs.")"https://taskjuice.ai/docs"
$extractDomain(text)The domain of an email address or web address, lowercased and without "www.".$extractDomain("ada@Example.com")"example.com"
$extractNumber(text)The first number in the text (commas and decimals understood); missing when there is none.$extractNumber("Total: $1,234.50 due")1234.5
$indexOf(value, search, start?)The position (from 0) of text inside text, or of a value in a list; -1 when absent.$indexOf("hello world", "o")4
$startsWith(text, prefix)True when the text begins with the prefix.$startsWith("INV-1042", "INV-")true
$endsWith(text, suffix)True when the text ends with the suffix.$endsWith("report.pdf", ".pdf")true
$capitalize(text)Uppercases the first letter and leaves the rest as it is.$capitalize("hello world")"Hello world"
$titleCase(text)Capitalizes each word, keeping short words like "of" and "the" lowercase inside the title.$titleCase("the lord of the rings")"The Lord of the Rings"
$sentenceCase(text)Lowercases the text and capitalizes the first letter of each sentence.$sentenceCase("HELLO THERE. HOW ARE YOU?")"Hello there. How are you?"
$snakeCase(text)Turns text into snake_case.$snakeCase("First Name")"first_name"
$camelCase(text)Turns text into camelCase.$camelCase("first name")"firstName"
$kebabCase(text)Turns text into kebab-case.$kebabCase("First Name")"first-name"
$truncate(text, maxLength, suffix?)Shortens text to at most maxLength characters, ending with "..." (or your suffix) when cut.$truncate("The quick brown fox", 12)"The quick..."
$stripHtml(text)Removes HTML tags (and scripts and styles), keeping line breaks and decoding entities like &amp;.$stripHtml("<p>Hello <b>Ada</b> &amp; team</p>")"Hello Ada & team"
$removeAccents(text)Replaces accented letters with plain ones (é → e, ß → ss).$removeAccents("Crème brûlée à Zürich")"Creme brulee a Zurich"

Numbers and money

FunctionWhat it doesExampleResult
$formatCurrency(amount, currency, locale?)Formats a number as money in a currency, written the way a locale writes it (en-US by default).$formatCurrency(1234.5, "USD")"$1,234.50"
$median(numbers)The middle number of a list (the average of the two middle numbers when the count is even).$median([3, 1, 4, 1, 5])3
$mode(list)The value that appears most often in a list (the earliest one on a tie).$mode(["red", "blue", "red"])"red"
$stdev(numbers, kind?)The standard deviation of a list of numbers: "sample" (the default, like a spreadsheet STDEV) or "population".$stdev([2, 4, 4, 4, 5, 5, 7, 9], "population")2

Lists and objects

Lists compare values by content, so two objects with the same fields count as the same value.

FunctionWhat it doesExampleResult
$chunk(list, size)Splits a list into smaller lists of the given size (the last one may be shorter).$chunk([1, 2, 3, 4, 5], 2)[[1,2],[3,4],[5]]
$range(start, end, step?)A list of whole numbers from start to end (both included), stepping by step; at most 10000 items.$range(1, 5)[1,2,3,4,5]
$union(list1, list2)Every value in either list, once each.$union([1, 2, 3], [3, 4])[1,2,3,4]
$intersection(list1, list2)The values that are in both lists.$intersection(["a", "b", "c"], ["b", "c", "d"])["b","c"]
$difference(list1, list2)The values in the first list that are not in the second.$difference(["a", "b", "c"], ["b"])["a","c"]
$distinctBy(list, field)Removes items whose field repeats an earlier item’s, keeping the first.$distinctBy([{"id": 1, "n": "a"}, {"id": 1, "n": "b"}, {"id": 2, "n": "c"}], "id")[{"id":1,"n":"a"},{"id":2,"n":"c"}]
$groupBy(list, field)Groups a list of objects by a field into an object of lists; items without the field go under "(none)".$groupBy([{"team": "red", "n": 1}, {"team": "blue", "n": 2}, {"team": "red", "n": 3}], "team"){"blue":[{"n":2,"team":"blue"}],"red":[{"n":1,"team":"red"},{"n":3,"team":"red"}]}
$flatten(list, depth?)Pulls nested lists up into one list, all the way down or only depth levels.$flatten([1, [2, [3, [4]]]])[1,2,3,4]
$pick(object, fields)A copy of the object with only the named fields.$pick({"name": "Ada", "email": "ada@example.com", "age": 36}, ["name", "email"]){"email":"ada@example.com","name":"Ada"}
$omit(object, fields)A copy of the object without the named fields.$omit({"name": "Ada", "password": "x"}, "password"){"name":"Ada"}
FunctionWhat it doesExampleResult
$uuid()A new random UUID (v4) on every call, including when a step retries.$length($uuid())36
$hash(text, algorithm?, encoding?)A hash of the text: sha256 by default, or md5, sha1, sha384, sha512; as hex or base64.$hash("hello")"2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824"
$hmac(text, key, algorithm?, encoding?)A keyed HMAC signature of the text, e.g. to check a webhook signature: sha256 by default, hex or base64.$hmac("hello", "secret")"88aab3ede8d3adf94d26ab90d3bafd4a2083070c3bcce9c014ee04a443847c0b"
$parseJson(text)Reads JSON text into a value. Safer than $eval, which runs the text as an expression.$parseJson("{\"total\": 42}").total42
$parseUrl(url)Splits a web address into protocol, hostname, port, path, query (as an object) and hash.$parseUrl("https://shop.example.com:8443/orders?id=42&tag=a&tag=b#top"){"hash":"top","host":"shop.example.com:8443","hostname":"shop.example.com","origin":"https://shop.example.com:8443","path":"/orders","port":"8443","protocol":"https","query":{"id":"42","tag":["a","b"]}}
$parseQuery(query)Reads a query string into an object; a repeated key becomes a list.$parseQuery("?page=2&sort=name"){"page":"2","sort":"name"}
$toQueryString(object)Turns an object into a URL query string; a list repeats its key, and empty values are left out.$toQueryString({"q": "red shoes", "page": 2})"q=red+shoes&page=2"

Coming from n8n, Make or Zapier

You usedWrite
n8n $json.created.toDateTime().format('yyyy-MM-dd')$formatDate($input.created, "yyyy-MM-dd")
n8n $now.plus(7, 'days')$addTime($now(), 7, "days")
n8n $ifEmpty(value, 'n/a'), Make ifempty(value; n/a)$ifEmpty(value, "n/a")
n8n .extractEmail(), Zapier Formatter "Extract Email Address"$extractEmail(text)
Make formatDate(date; YYYY-MM-DD; Europe/London)$formatDate(date, "yyyy-MM-dd", "Europe/London")
Make addDays(date; 3), Zapier "Add/Subtract Time"$addTime(date, 3, "days")
Make md5(text) / sha256(text)$hash(text, "md5") / $hash(text)
Zapier Formatter "Truncate"$truncate(text, 100)
Zapier Formatter "Titlecase"$titleCase(text)
Power Automate convertTimeZone(...)$convertTimezone(date, "Asia/Tokyo")

Built-in JSONata behaviour to watch for

A few JSONata built-ins behave differently from what you might expect. TaskJuice leaves them as they are so existing workflows keep working.

Built-inWhat it doesWhen you want something else
$boolean("false")Returns true, because any non-empty text counts as true$toBoolean("false") returns false
$substring(text, start, length)The third argument is a length, not an end positionCount the length: $substring("abcdef", 1, 3) is "bcd"
$round(2.5)Rounds halves to the even number, so this is 2$floor(n + 0.5) always rounds halves up
$trim(text)Also squeezes repeated spaces inside the text into oneUse $replace(text, /^\s+|\s+$/, "") to trim only the ends

Good to know

  • $uuid() and $now() give a new value every time, including when a step retries.
  • $range builds at most 10,000 numbers.
  • In the mapping preview, an expression can make up to 1,000 function calls.
Was this helpful?