DataWeave 2.0 core functions cheatsheet

Updated: Sep 4, 2021



This is a compilation of all the core functions that can be used in DataWeave 2.0 according to MuleSoft's official documentation, separated by input and output.


The link to each function's official documentation page is provided in the list. There you can find more details about the functions and examples on how to use them.


You can use ctrl+F or cmd+F to search for specific keywords and get to the function you're looking for.



List of functions


Array to Array

Input: Array

Output: Array

  • Plus plus (++) - Concatenates two arrays into a new array.

  • Minus minus (--) - Removes items listed in the second array from the first array.

  • distinctBy - Iterates over an array and returns the unique elements in it.

  • filter - Iterates over an array and returns the matching values from a given expression.

  • find - Returns an array with the indices (or indexes) of the elements from the array that matched a specific value.

  • flatMap - Iterates over each item in an array and flattens the results.

  • flatten - Turns a set of subarrays into a single, flattened array.

  • map - Iterates over items in an array and outputs the result into a new array.

  • maxBy - Iterates over the array and returns the highest array according to the provided expression.

  • minBy - Iterates over the array and returns the lowest array according to the provided expression.

  • orderBy - Reorders the array's elements based on the given criteria.

  • reduce - Applies a reduction expression to the elements in the array.

  • unzip - Groups the values of the given sub-arrays by matching indices (or indexes) and returns new sub-arrays with the matching indices. Note: performs the opposite of zip.

  • zip - Merges elements from two arrays into an array of arrays. Note: performs the opposite of unzip.


Array to Boolean

Input: Array

Output: Boolean

  • contains - Returns true if the array contains a given value, otherwise false.

  • isEmpty - Returns true if the array is empty, otherwise false.

  • max - Returns the highest boolean in the given array.

  • maxBy - Iterates over the array and returns the highest boolean according to the provided expression.

  • min - Returns the lowest boolean in the given array.

  • minBy - Iterates over the array and returns the lowest boolean according to the provided expression.

  • reduce - Applies a reduction expression to the elements in the array.


Array to Date

Input: Array

Output: Date

  • max - Returns the highest date in the given array.

  • maxBy - Iterates over the array and returns the highest date according to the provided expression.

  • min - Returns the lowest date in the given array.

  • minBy - Iterates over the array and returns the lowest date according to the provided expression.


Array to DateTime

Input: Array

Output: DateTime

  • max - Returns the highest datetime in the given array.

  • maxBy - Iterates over the array and returns the highest datetime according to the provided expression.

  • min - Returns the lowest datetime in the given array.

  • minBy - Iterates over the array and returns the lowest datetime according to the provided expression.


Array to LocalDateTime

Input: Array

Output: LocalDateTime

  • max - Returns the highest localdatetime in the given array.

  • maxBy - Iterates over the array and returns the highest localdatetime according to the provided expression.

  • min - Returns the lowest localdatetime in the given array.

  • minBy - Iterates over the array and returns the lowest localdatetime according to the provided expression.


Array to LocalTime

Input: Array

Output: LocalTime

  • max - Returns the highest localtime in the given array.

  • maxBy - Iterates over the array and returns the highest localtime according to the provided expression.

  • min - Returns the lowest localtime in the given array.

  • minBy - Iterates over the array and returns the lowest localtime according to the provided expression.


Array to Number

Input: Array

Output: Number

  • avg - Returns the average of numbers listed in the array.

  • max - Returns the highest number in the given array.

  • maxBy - Iterates over the array and returns the highest number according to the provided expression.

  • min - Returns the lowest number in the given array.

  • minBy - Iterates over the array and returns the lowest number according to the provided expression.

  • reduce - Applies a reduction expression to the elements in the array.

  • sizeOf - Returns the number of elements in an array.

  • sum - Returns the sum of numeric values in the given array.


Array to Object

Input: Array

Output: Object

  • groupBy - Returns an object that groups items from an array based on specific criteria.

  • maxBy - Iterates over the array and returns the highest object according to the provided expression.

  • minBy - Iterates over the array and returns the lowest object according to the provided expression.

  • reduce - Applies a reduction expression to the elements in the array.


Array to String

Input: Array

Output: String

  • joinBy - Merges the array into a string and uses the provided string as separator between each item. Note: this is the opposite operation of splitBy.

  • max - Returns the highest string in the given array.

  • maxBy - Iterates over the array and returns the highest string according to the provided expression.

  • min - Returns the lowest string in the given array.

  • minBy - Iterates over the array and returns the lowest string according to the provided expression.

  • reduce - Applies a reduction expression to the elements in the array.


Array to Time

Input: Array

Output: Time

  • max - Returns the highest time in the given array.

  • maxBy - Iterates over the array and returns the highest time according to the provided expression.

  • min - Returns the lowest time in the given array.

  • minBy - Iterates over the array and returns the lowest time according to the provided expression.


Array to TimeZone

Input: Array

Output: TimeZone

  • max - Returns the highest timezone in the given array.

  • maxBy - Iterates over the array and returns the highest timezone according to the provided expression.

  • min - Returns the lowest timezone in the given array.

  • minBy - Iterates over the array and returns the lowest timezone according to the provided expression.


Array and String to String

Input: Array

Input: String

Output: String

  • joinBy - Merges the array into a string and uses the provided string as separator between each item. Note: this is the opposite operation of splitBy.


Date to Boolean

Input: Date

Output: Boolean

  • isLeapYear - Returns true if the provided date is a leap year, otherwise false.


Date to Number

Input: Date

Output: Number

  • daysBetween - Returns the number of days between two dates.


Date and LocalTime to LocalDateTime

Input: Date

Input: LocalTime

Output: LocalDateTime

  • Plus plus (++) - Concatenates a date and a localtime to create a localdatetime.


Date and Time to DateTime

Input: Date

Input: Time

Output: DateTime


Date and TimeZone to DateTime

Input: Date

Input: TimeZone

Output: DateTime

  • Plus plus (++) - Concatenates a date and a timezone to create a datetime.


DateTime to Boolean

Input: DateTime

Output: Boolean

  • isLeapYear - Returns true if the provided datetime is a leap year, otherwise false.


LocalTime and Date to LocalDateTime

Input: LocalTime

Input: Date

Output: LocalDateTime

  • Plus plus (++) - Concatenates a localtime and a date to create a localdatetime.


LocalTime and TimeZone to Time

Input: LocalTime

Input: TimeZone

Output: Time

  • Plus plus (++) - Concatenates a localtime and a timezone to create a time.


LocalDateTime to Boolean

Input: LocalDateTime

Output: Boolean

  • isLeapYear - Returns true if the provided localdatetime is a leap year, otherwise false.


LocalDateTime and TimeZone to DateTime

Input: LocalDateTime

Input: TimeZone

Output: DateTime

  • Plus plus (++) - Concatenates a localdatetime and a timezone to create a datetime.


Number to Array

Input: Number

Output: Array

  • to - Returns a range with the given numbers.


Number to Boolean

Input: Number

Output: Boolean

  • isDecimal - Returns true if the given number contains a decimal, otherwise false.

  • isEven - Returns true if the given number is even, otherwise false.

  • isInteger - Returns true if the given number is an integer, otherwise false.

  • isOdd - Returns true if the given number is odd, otherwise false.


Number to Number

Input: Number

Output: Number

  • abs - Returns the absolute value of the number.

  • ceil - Rounds the number up to the nearest number.

  • floor - Rounds the number down to the nearest number.

  • mod - Returns the modulo (the remainder after dividing the dividend by the divisor).

  • pow - Raises the value of the given base number to the given power.

  • randomInt - Returns a pseudo-random whole number from 0 to the given number.

  • round - Rounds the number up or down to the nearest number.

  • sqrt - Returns the square root of the given number.


Number to Range

Input: Number

Output: Range

  • to - Returns a range with the given numbers.


Object to Array

Input: Object

Output: Array

  • entriesOf - Returns an array of key/value pairs that describe the key, value, and any attributes in the input object.

  • keysOf - Returns an array of keys from the given object.

  • namesOf - Returns an array of strings with the names of the keys from the given object.

  • pluck - Iterates over an object and returns an array of keys, values, or indices (or indexes) from the object. Useful for mapping an object into an array. Note: similar to mapObject - mapObject returns an object and pluck returns an array.

  • valuesOf - Returns an array of the values from the given object's key/value pairs.


Object to Boolean

Input: Object

Output: Boolean

  • isEmpty - Returns true if the object is empty, otherwise false.


Object to Number

Input: Object

Output: Number

  • sizeOf - Returns the number of key/value pairs in an object.


Object to Object

Input: Object

Output: Object

  • Plus plus (++) - Concatenates two objects into a new object.

  • Minus minus (--) - Removes key/value pairs listed in the second object from the first object.

  • distinctBy - Removes duplicate key/value pairs from the object.

  • filterObject - Iterates through the key/value pairs from the object and returns the matching key/value pairs from a given expression.

  • groupBy - Iterates through the object's elements and groups them based on the given criteria.

  • mapObject - Iterates over the object using a mapper that acts on keys, values, or indices (or indexes) of that object. Note: similar to pluck - mapObject returns an object and pluck returns an array.

  • orderBy - Reorders the object's elements based on the given criteria.


Object and Array to Object

Input: Object

Input: Array

Output: Object


String to Array

Input: String

Output: Array

  • find - Returns an array with the indices (or indexes) of the characters from the string that matched a specific regular expression.

  • splitBy - Splits the given string into an array based on the given separating string. Note: this is the opposite operation of joinBy.


String to Boolean

Input: String

Output: Boolean

  • contains - Returns true if the string contains a given substring, otherwise false.

  • endsWith - Returns true if the string ends with the given substring, otherwise false.

  • isBlank - Returns true if the given string is empty, composed of whitespaces, or null; otherwise false.

  • isDecimal - Returns true if the given number contains a decimal, otherwise false. Note: this function is designed for Number instead of String. You will receive a warning from DataWeave, or an error if the provided String contains something that can't be coerced into Number.

  • isEmpty - Returns true if the string is empty, otherwise false.

  • startsWith - Returns true if the string starts with the given substring, otherwise false.


String to Number

Input: String

Output: Number

  • sizeOf - Returns the number of characters in a string.


String to String

Input: String

Output: String

  • Plus plus (++) - Concatenates two strings into a new string.

  • lower - Returns the given string in lowercase characters.

  • replace (with) - Performs a string replacement from the given substring with the provided string.

  • trim - Removes any blank spaces from the beginning and end of the given string.

  • upper - Returns the given string in uppercase characters.


String and Regex to Array

Input: String

Input: Regex

Output: Array

  • find - Returns an array with the indices (or indexes) of the elements from the string that matched a specific regular expression.

  • match - Matches the given regular expression from the given string and separates the results into capture groups inside an array. Note: match will return a full match from the string. For several matches, use scan instead.