Functions in n8n are accessed using dot notation (.) directly on a variable. The variable must first be accessed from a previous node, often under the standard JavaScript Object Notation (JSON) structure.
Standard Calling Convention:$json.data_type.functionName(parameter1, parameter2)
$json.data_type: References the variable you are acting upon (e.g., json.string, json.number, json.array, json.object, or json.boolean)..: The period opens the function editor and provides access to the library.functionName: The name of the function being applied (e.g., split, round, length).(): Parentheses are used to pass necessary parameters or arguments.length or object keys) are parameters, not functions, and are called without parentheses (.length).| Usage | Purpose | Example |
|---|---|---|
| Variable Access | Use the dollar sign ($) to access data from the input nodes. The format is $json.variable_name. |
$json.string (Accesses a variable named "string") |
| Calling Functions | Add a period (.) after the variable, followed by the function name and parentheses (). |
$json.number.round() |
| Properties | Properties (like length) are called without parentheses. |
$json.array.length |
| String/Regex Parameters | Any literal text or pattern must be wrapped in quotes. | .split(',') or .replace('old', 'new') |
$now FunctionThe $now function is used to grab the current date and time.
$now.toDateTime() on it.$now.format('YYYY-MM-DD') (Formats the current time into a specific date string).These functions operate on text variables (strings), accessed via $json.string.
| Function Name | How to Call It | What It Does | Example |
|---|---|---|---|
| includes | .includes('substring') |
Checks if the string contains a specified sequence of characters. | json.string.includes('hell') returns true. |
| split | .split('delimiter') |
Converts the string into an array, breaking it up wherever the delimiter is found. | Splitting "Sarah, Sally" by ", " yields ["Sarah", "Sally"]. |
| startsWith | .startsWith('characters') |
Checks if the string begins with the specified characters. | "hello!".startsWith('h e l l') returns true. |
| endsWith | .endsWith('characters') |
Checks if the string ends with the specified characters. | "hello!".endsWith('o!') returns true. |
| replaceAll | .replaceAll('pattern', 'replacement') |
Replaces every occurrence of a pattern or substring with a new replacement string. | Replacing all "L" with "W" in "Hello!" results in "Hewwo!". |
| length | .length |
Returns the total number of characters in the string (not a function, but a parameter). | The length of "hello!" is 6. |
| base64Encode | .base64Encode() |
Encodes the string into the Base64 format (often used for API keys). | Encoding "hello" yields a Base64 string. |
| base64Decode | .base64Decode() |
Decodes a Base64 string back into plain text. | Decoding a Base64 string yields "hello!". |
| concat | .concat('addition') |
Appends one or more additional strings (or an array of strings) to the end of the current string (String addition). | json.string.concat(' world') yields "Hello! world". |
| extractDomain | .extractDomain() |
Pulls out the root domain name from a URL or email string. | Extracts left-click.ai from nick@left-click.ai. |
| extractEmail | .extractEmail() |
Extracts an email address (looks for string@domain) from a body of text. |
Extracts nick@left-click.ai from a large scraped text block. |
| extractURL | .extractURL() |
Extracts the full URL (must include the protocol, e.g., HTTP or FTP). | Extracts https://left-click.ai. |
| extractURLPath | .extractURLPath() |
Extracts everything that follows the first slash after the domain name. | Extracts /workflow/ID from an n8n Cloud URL. |
| hash | .hash('algorithm') |
Applies a hashing algorithm (e.g., md5, sha256) to convert the string into a long hexadecimal number for security. |
Hashing "hello" using sha1 results in a unique hexadecimal string. |
| quote | .quote('mark') |
Wraps the string in quotation marks and automatically "escapes" internal quotes with a backslash for data sanitation. | Sanitizes a string containing quotes (e.g., "Nick says 'hi'"). |
| removeMarkdown | .removeMarkdown() |
Removes markdown formatting conventions (like # for headings). |
Applying to # Heading One yields Heading One. |
| removeTags | .removeTags() |
Removes HTML tags (like <H1>) from the string, yielding plain text. |
Removes all HTML from scraped webpage data. |
| replace | .replace('pattern', 'replacement') |
Replaces only the first instance of a specified character or substring. | Replacing "L" with "W" in "Hello!" yields "Hewlo!". |
| replaceSpecialCars | .replaceSpecialCars() |
Removes special accented or marked characters that can cause issues with older APIs. | Inputting a string with é yields the same string with e. |
| slice | .slice(start, end) |
Extracts a substring by specifying the starting and optional ending index (zero-indexed). | Slicing "hello!" from 0 to 4 yields "hell". |
| substring | .substring(start, end) |
Identical function to slice. |
json.string.substring(0, 4) yields "hell". |
| trim | .trim() |
Removes white space (spaces, tabs, new lines) from both the beginning and the end of the string. | Trimming " test string " yields "test string". |
| trimEnd | .trimEnd() |
Removes only the trailing white space from the end of the string. | Trimming end of " test " yields " test". |
| trimStart | .trimStart() |
Removes only the leading white space from the start of the string. | Trimming start of " test " yields "test ". |
| urlEncode | .urlEncode() |
Converts illegal URL characters (like spaces) into URL-safe encoding (e.g., %20). |
URL encoding a string like "blog post with awesome name". |
| urlDecode | .urlDecode() |
Converts URL-safe encoded characters back into their original form. | Decoding a URL-encoded string. |
| indexOf | .indexOf('substring') |
Returns the starting index (position) of the first occurrence of a substring. | json.string.indexOf('l') on "hello!" yields 2. |
| lastIndexOf | .lastIndexOf('substring') |
Returns the starting index (position) of the last occurrence of a substring. | json.string.lastIndexOf('l') on "hello!" yields 3. |
| match | .match(/regex/) |
Uses regular expressions (regex) to find and extract patterns within the string. | Using regex to extract all three-letter words from a phrase. |
| search | .search(/regex/) |
Uses regular expressions to return the index (position) where the first match occurs. | Searching for a specific pattern using regex. |
| isDomain | .isDomain() |
Validation: Checks if the string is formatted specifically as a domain name. | isDomain('left-click.ai') returns true. |
| isEmail | .isEmail() |
Validation: Checks if the string is formatted as an email address. | isEmail('nick@left-click.ai') returns true. |
| isEmpty | .isEmpty() |
Validation: Checks if the string has a length of zero. | isEmpty('') returns true. |
| isNot(E)mpty | .isNot(E)mpty() |
Validation: Checks if the string has a length greater than zero. | isNot(E)mpty('test') returns true. |
| isNumeric | .isNumeric() |
Validation: Checks if the string contains only numeric characters. | isNumeric('123.4') returns true. |
| isURL | .isURL() |
Validation: Checks if the string is a complete URL (including protocol). | isURL('<https://left-click.ai>') returns true. |
| toLowerCase | .toLowerCase() |
Converts all characters in the string to lowercase. | Converts "Hello" to "hello". |
| toSentenceCase | .toSentenceCase() |
Capitalizes only the first letter of the entire string. | Converts "ways to make money" to "Ways to make money". |
| toSnakeCase | .toSnakeCase() |
Converts the string into variable names using underscores (_) instead of spaces. |
Converts "make money online" to "make_money_online". |
| toTitleCase | .toTitleCase() |
Capitalizes the first letter of all major words. | Converts a title into standard Title Case. |
| toUpperCase | .toUpperCase() |
Converts all characters in the string to uppercase. | Converts "hello" to "HELLO". |
| parseJson | .parseJson() |
Conversion: Converts a JSON-formatted string into an accessible JavaScript object data type. | Parses string '{"name": "Peter"}' into an object {name: Peter}. |
| toBoolean | .toBoolean() |
Conversion: Converts the string "1" to true or "0" to false (Boolean data type). |
String "1" converts to true. |
| toDateTime | .toDateTime() |
Conversion: Converts a date/time string into the standardized Luxon datetime object format. | Converts "01/31/2025" into a Luxon datetime object. |
| toNumber | .toNumber() |
Conversion: Converts a string containing numeric characters into a Number data type, enabling math. | Converts string "123504" into a number, allowing addition (e.g., + 5). |