![](https://static.wixstatic.com/media/e0d344_21cd557613524dc9b01ed0a606ff4fec~mv2.png/v1/fill/w_78,h_52,al_c,q_85,usm_0.66_1.00_0.01,blur_2,enc_auto/e0d344_21cd557613524dc9b01ed0a606ff4fec~mv2.png)
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 of 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.
⚠️ Important This cheatsheet has been last updated for DataWeave version 2.5 (Mule 4.5). You can find the last updates (from 2.3 to 2.5) with the following marks: ⭐️ NEWLY ADDED ⭐️
List of functions
Array to Array
Input: Array
Output: Array
Plus plus (++) - Concatenates two values.
Minus minus (--) - Removes specified values from an input value.
distinctBy - Iterates over the input and returns the unique elements in it.
filter - Iterates over an array and applies an expression that returns matching values.
find - Returns indices of an input that match a specified 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 value of Comparable elements from it.
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 an input contains a given value, false if not.
isEmpty - Returns true if the given input value is empty, false if not.
max - Returns the highest Comparable value in the given array.
maxBy - Iterates over the array and returns the highest value of Comparable elements from it.
min - Returns the lowest Comparable value 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 Comparable value in the given array.
maxBy - Iterates over the array and returns the highest value of Comparable elements from it.
min - Returns the lowest Comparable value 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 Comparable value in the given array.
maxBy - Iterates over the array and returns the highest value of Comparable elements from it.
min - Returns the lowest Comparable value 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 Comparable value in the given array.
maxBy - Iterates over the array and returns the highest value of Comparable elements from it.
min - Returns the lowest Comparable value 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 Comparable value in the given array.
maxBy - Iterates over the array and returns the highest value of Comparable elements from it.
min - Returns the lowest Comparable value 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.
indexOf - Returns the index of the first occurrence of the specified element in this array, or -1 if this list does not contain the element. ⭐️ NEWLY ADDED ⭐️
lastIndexOf - Returns the index of the last occurrence of the specified element in a given array, or -1 if the array does not contain the element. ⭐️ NEWLY ADDED ⭐️
max - Returns the highest Comparable value in the given array.
maxBy - Iterates over the array and returns the highest value of Comparable elements from it.
min - Returns the lowest Comparable value 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 specified criteria, such as an expression or matching selector.
maxBy - Iterates over the array and returns the highest value of Comparable elements from it.
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 an array into a string and uses the provided string as a separator between each item in the list. Note: this is the opposite operation of splitBy.
max - Returns the highest Comparable value in the given array.
maxBy - Iterates over the array and returns the highest value of Comparable elements from it.
min - Returns the lowest Comparable value 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 Comparable value in the given array.
maxBy - Iterates over the array and returns the highest value of Comparable elements from it.
min - Returns the lowest Comparable value 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 Comparable value in the given array.
maxBy - Iterates over the array and returns the highest value of Comparable elements from it.
min - Returns the lowest Comparable value 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 an array into a string and uses the provided string as a separator between each item in the list. Note: this is the opposite operation of splitBy.
Date to Boolean
Input: Date
Output: Boolean
isLeapYear - Returns true if it receives a date for a leap year, false. if not.
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 two values.
Date and Time to DateTime
Input: Date
Input: Time
Output: DateTime
Plus plus (++) - Concatenates two values.
Date and TimeZone to DateTime
Input: Date
Input: TimeZone
Output: DateTime
Plus plus (++) - Concatenates two values.
DateTime to Boolean
Input: DateTime
Output: Boolean
isLeapYear - Returns true if it receives a date for a leap year, false. if not.
LocalTime and Date to LocalDateTime
Input: LocalTime
Input: Date
Output: LocalDateTime
Plus plus (++) - Concatenates two values.
LocalTime and TimeZone to Time
Input: LocalTime
Input: TimeZone
Output: Time
Plus plus (++) - Concatenates two values.
LocalDateTime to Boolean
Input: LocalDateTime
Output: Boolean
isLeapYear - Returns true if it receives a date for a leap year, false. if not.
LocalDateTime and TimeZone to DateTime
Input: LocalDateTime
Input: TimeZone
Output: DateTime
Plus plus (++) - Concatenates two values.
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 number or numeric result of a mathematical operation is even, false if not.
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 a number.
ceil - Rounds the number up to the nearest whole number.
floor - Rounds a number down to the nearest whole 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 key-value pairs within the input 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 given input value is empty, false if not.
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 values.
Minus minus (--) - Removes specified values from an input value.
distinctBy - Iterates over the input and returns the unique elements in it.
filterObject - Iterates a list of key-value pairs in an object and applies an expression that returns only matching objects, filtering out the rest from the output.
groupBy - Groups elements of an object based on criteria that the groupBy uses to iterate over elements in the input.
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
Minus minus (--) - Removes specified values from an input value.
String to Array
Input: String
Output: Array
String to Boolean
Input: String
Output: Boolean
contains - Returns true if an input contains a given value, false if not.
endsWith - Returns true if a string ends with a provided substring, false if not.
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 given input value is empty, false if not.
startsWith - Returns true if the string starts with the given substring, otherwise false.
String to Number
Input: String
Output: Number
indexOf - Returns the index of the first occurrence of the specified string in this string, or -1 if this list does not contain the element. ⭐️ NEWLY ADDED ⭐️
lastIndexOf - Returns the index of the last occurrence of the specified element in a given array, or -1 if the array does not contain the element. ⭐️ NEWLY ADDED ⭐️
sizeOf - Returns the number of characters in a string.
String to Object ⭐️ NEWLY ADDED ⭐️
Input: String
Output: Object
groupBy - Returns an object that groups characters from a string based on specified criteria, such as an expression or matching selector.
String to String
Input: String
Output: String
Plus plus (++) - Concatenates two values.
filter - Iterates over a string and applies an expression that returns matching values. ⭐️ NEWLY ADDED ⭐️
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 indices of an input that match a specified value.
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.
scan - Returns an array with all of the matches found in the given string, using the given regular expression. Note: scan will return all of the matches from the string. For a full match, use match instead.
splitBy - Splits the given string into an array based on the regular expression. Note: this is the opposite operation of joinBy.
String and Regex to Boolean
Input: String
Input: Regex
Output: Boolean
String and Regex to String
Input: String
Input: Regex
Output: String
replace (with) - Performs a string replacement from the substring found with the given regular expression.
Time and Date to DateTime
Input: Time
Input: Date
Output: DateTime
Plus plus (++) - Concatenates two values.
TimeZone and Date to DateTime
Input: TimeZone
Input: Date
Output: DateTime
Plus plus (++) - Concatenates two values.
TimeZone and LocalDateTime to DateTime
Input: TimeZone
Input: LocalDateTime
Output: DateTime
Plus plus (++) - Concatenates two values.
TimeZone and LocalTime to DateTime
Input: TimeZone
Input: LocalTime
Output: DateTime
Plus plus (++) - Concatenates two values.
Others
Some of these next functions don't have any input parameters or don't return any output. Some accept more than two arguments.
log - Without changing the value of the input, log returns the input as a system log. So this makes it very simple to debug your code, because any expression or subexpression can be wrapped with log and the result will be printed out without modifying the result of the expression. The output is going to be printed in application/dw format.
match / case - Pattern matching can be achieved by using a combination of match and case. Can be applied to literal values, expressions, data types, or regular expressions.
now - Returns current date and time in a DateTime.
random - Returns a pseudo-random number between 0.0 and 1.0.
read - Reads a string or binary and returns parsed content (for example: application/json, application/xml, application/csv, etc.).
readUrl - Reads a URL, including a classpath-based URL, and returns parsed content. Note: similar to the read function.
typeOf - Returns the type of the given value.
uuid - Returns a v4 UUID using random numbers as the source.
write - Writes a value as a string or binary in a supported format.
xsiType - Creates a xsi:type type attribute. Note: useful for XML data types.
Additional to the plus plus (++) function, you can also concatenate objects by using the Object Destructor {( )}. Learn more about this approach here or learn how to use $( ) to concatenate strings here.
Null-safe functions
Here is a list of the functions that don't need an additional null-checker implemented.
In other words, they accept null values and won't throw any error.
If you have any suggestions, comments, or noticed that something's wrong with the provided information; please reach out with a comment on this post or contact us here.
I hope this was useful for you!
-Alex