String Methods
String methods are used to process and transform string data.
Method Reference
length
Returns the length of the string (number of characters).
Returns: Number
Examples:
{{ "hello".length }}
// 5
{{ "".length }}
// 0
{{ $('Chat Trigger').message.length }}
// Get message lengthbase64Encode()
Encodes a string to Base64.
Returns: String (Base64 encoded string)
Examples:
{{ "hello world".base64Encode() }}
// "aGVsbG8gd29ybGQ="
{{ $('Chat Trigger').message.base64Encode() }}
// Encode message to Base64base64Decode()
Converts a Base64 encoded string to a plain string.
Returns: String (Decoded plain string)
Examples:
{{ "aGVsbG8gd29ybGQ=".base64Decode() }}
// "hello world"
{{ $('HTTP Request').body.encodedData.base64Decode() }}
// Decode Base64 dataextractDomain()
Extracts the domain from a string containing a valid URL. Returns undefined if no domain is found.
Returns: String | undefined
Examples:
{{ "https://www.example.com/path".extractDomain() }}
// "www.example.com"
{{ "Visit https://github.com for more info".extractDomain() }}
// "github.com"
{{ $('HTTP Request').body.url.extractDomain() }}
// Extract domain from URLextractEmail()
Extracts an email address from a string. Returns undefined if none found. Returns the first email if multiple exist.
Returns: String | undefined
Examples:
{{ "Contact us at info@example.com".extractEmail() }}
// "info@example.com"
{{ "Email: john@test.com or support@test.com".extractEmail() }}
// "john@test.com" (returns first)
{{ $('Chat Trigger').message.extractEmail() }}
// Extract email from messageextractUrl()
Extracts a URL from a string. Returns undefined if none found. Returns the first URL if multiple exist. Limited to http(s) protocol.
Returns: String | undefined
Examples:
{{ "Visit https://example.com for more".extractUrl() }}
// "https://example.com"
{{ "Check http://test.com and https://demo.com".extractUrl() }}
// "http://test.com" (returns first)
{{ $('Chat Trigger').message.extractUrl() }}
// Extract URL from messageextractUrlPath()
Extracts the path from a URL, excluding the root domain.
Returns: String
Examples:
{{ "https://example.com/orders/1/details".extractUrlPath() }}
// "/orders/1/details"
{{ "https://api.example.com/v1/users".extractUrlPath() }}
// "/v1/users"
{{ $('HTTP Request').body.url.extractUrlPath() }}
// Extract URL pathhash(algo?: Algorithm)
Returns the hash of a string using the specified algorithm.
Parameters:
algo(Algorithm, optional): Hash algorithm to use. Values:md5(default),base64,sha1,sha224,sha256,sha384,sha512,sha3,ripemd160
Returns: String
Examples:
{{ "hello world".hash() }}
// Default uses md5
// "5eb63bbbe01eeed093cb22bb8f5acdc3"
{{ "hello world".hash("md5") }}
// "5eb63bbbe01eeed093cb22bb8f5acdc3"
{{ "hello world".hash("sha256") }}
// "b94d27b9934d3e08a52e52d7da7dabfac484efe37a5380ee9088f7ace2efcde9"
{{ $('Chat Trigger').message.hash("sha256") }}
// Generate SHA-256 hash of messageisDomain()
Checks if a string is a domain.
Returns: Boolean
Examples:
{{ "example.com".isDomain() }}
// true
{{ "www.example.com".isDomain() }}
// true
{{ "not-a-domain".isDomain() }}
// false
{{ "https://example.com".isDomain() }}
// false (contains protocol, not a pure domain)
{{ $('HTTP Request').body.domain.isDomain() }}
// Validate if it's a valid domainisEmail()
Checks if a string is an email address.
Returns: Boolean
Examples:
{{ "user@example.com".isEmail() }}
// true
{{ "invalid-email".isEmail() }}
// false
{{ $('HTTP Request').body.email.isEmail() }}
// Validate email formatisEmpty()
Checks if a string is empty.
Returns: Boolean
Examples:
{{ "".isEmpty() }}
// true
{{ "hello".isEmpty() }}
// false
{{ $('Chat Trigger').message.isEmpty() }}
// Check if message is emptyisNotEmpty()
Checks if a string is not empty.
Returns: Boolean
Examples:
{{ "hello".isNotEmpty() }}
// true
{{ "".isNotEmpty() }}
// false
{{ $('Chat Trigger').message.isNotEmpty() }}
// Check if message is not emptyisNumeric()
Checks if a string contains only numbers (including floats and scientific notation).
Returns: Boolean
Examples:
{{ "123".isNumeric() }}
// true
{{ "3.14".isNumeric() }}
// true
{{ "1.2e-3".isNumeric() }}
// true (scientific notation)
{{ "abc".isNumeric() }}
// false
{{ $('Chat Trigger').message.isNumeric() }}
// Check if input is numericisUrl()
Checks if a string is a valid URL (valid format).
Returns: Boolean
Examples:
{{ "https://example.com".isUrl() }}
// true
{{ "http://test.com/path".isUrl() }}
// true
{{ "not-a-url".isUrl() }}
// false
{{ $('HTTP Request').body.url.isUrl() }}
// Validate URL formatparseJson()
Equivalent to JSON.parse(). Parses a string as a JSON object.
Returns: Object | Array
Examples:
{{ '{"name":"Alice","age":25}'.parseJson() }}
// { name: "Alice", age: 25 }
{{ '[1,2,3]'.parseJson() }}
// [1, 2, 3]
{{ $('HTTP Request').body.jsonString.parseJson() }}
// Parse JSON stringquote(mark?: String)
Returns a string wrapped in quotes. Default quote is ". Automatically handles escaping.
Parameters:
mark(String, optional): Quote character. Default:"
Returns: String
Examples:
{{ "hello".quote() }}
// "\"hello\""
{{ "hello".quote("'") }}
// "'hello'"
{{ 'say "hello"'.quote() }}
// "\"say \\\"hello\\\"\""
{{ $('Chat Trigger').message.quote() }}
// Add quotes to messageremoveMarkdown()
Removes Markdown formatting from a string.
Returns: String
Examples:
{{ "# Hello\n**bold** text".removeMarkdown() }}
// "Hello\nbold text"
{{ $('HTTP Request').body.markdown.removeMarkdown() }}
// Remove Markdown formattingremoveTags()
Removes tags from a string, such as HTML or XML tags.
Returns: String
Examples:
{{ "<p>Hello <strong>World</strong></p>".removeTags() }}
// "Hello World"
{{ "<div>Test</div>".removeTags() }}
// "Test"
{{ $('HTTP Request').body.html.removeTags() }}
// Remove HTML tagstoBoolean()
Converts a string to a boolean. "false", "0", "", and "no" convert to false.
Returns: Boolean
Examples:
{{ "true".toBoolean() }}
// true
{{ "false".toBoolean() }}
// false
{{ "0".toBoolean() }}
// false
{{ "".toBoolean() }}
// false
{{ "no".toBoolean() }}
// false
{{ "yes".toBoolean() }}
// true
{{ "hello".toBoolean() }}
// true
{{ $('HTTP Request').body.flag.toBoolean() }}
// Convert string flag to booleantoDecimalNumber()
Converts a string to a decimal number.
Returns: Number
Examples:
{{ "3.14".toDecimalNumber() }}
// 3.14
{{ "42".toDecimalNumber() }}
// 42
{{ $('Chat Trigger').message.toDecimalNumber() }}
// Convert input to decimal numbertoFloat()
Converts a string to a floating-point number.
Returns: Number
Examples:
{{ "3.14".toFloat() }}
// 3.14
{{ "42".toFloat() }}
// 42.0
{{ $('HTTP Request').body.price.toFloat() }}
// Convert price string to floattoInt()
Converts a string to an integer.
Returns: Number
Examples:
{{ "42".toInt() }}
// 42
{{ "3.14".toInt() }}
// 3
{{ "1.2e3".toInt() }}
// 1200
{{ $('Chat Trigger').message.toInt() }}
// Convert input to integertoSentenceCase()
Formats a string to sentence case. Only capitalizes the first letter, rest lowercase.
Returns: String
Examples:
{{ "hello world".toSentenceCase() }}
// "Hello world"
{{ "HELLO WORLD".toSentenceCase() }}
// "Hello world"
{{ $('Chat Trigger').message.toSentenceCase() }}
// Convert message to sentence casetoSnakeCase()
Formats a string to snake_case. Only supports ASCII characters.
Returns: String
Examples:
{{ "helloWorld".toSnakeCase() }}
// "hello_world"
{{ "HelloWorld".toSnakeCase() }}
// "hello_world"
{{ "hello-world".toSnakeCase() }}
// "hello_world"
{{ $('HTTP Request').body.fieldName.toSnakeCase() }}
// Convert field name to snake_casetoKebabCase()
Formats a string to kebab-case. Spaces and underscores are replaced by hyphens, symbols are removed, all letters are lowercased, and consecutive dashes are collapsed.
Returns: String
Examples:
{{ "Hello_world Test".toKebabCase() }}
// "hello-world-test"
{{ "helloWorld".toKebabCase() }}
// "helloworld"
{{ "hello-world".toKebabCase() }}
// "hello-world"
{{ "quick brown $FOX".toKebabCase() }}
// "quick-brown-fox"
{{ $('HTTP Request').body.fieldName.toKebabCase() }}
// Convert field name to kebab-casetoCamelCase()
Formats a string to camelCase. The first word is lowercased, and subsequent words have their first letter capitalized. Spaces, underscores, and hyphens are removed, and symbols are stripped.
Returns: String
Examples:
{{ "hello_world".toCamelCase() }}
// "helloWorld"
{{ "hello world test".toCamelCase() }}
// "helloWorldTest"
{{ "HelloWorld".toCamelCase() }}
// "helloWorld"
{{ $('HTTP Request').body.fieldName.toCamelCase() }}
// Convert field name to camelCasetoPascalCase()
Formats a string to PascalCase. The first letter of each word is capitalized, and all other letters are lowercased. Spaces, underscores, and hyphens are removed, and symbols are stripped.
Returns: String
Examples:
{{ "hello_world test".toPascalCase() }}
// "HelloWorldTest"
{{ "hello world".toPascalCase() }}
// "HelloWorld"
{{ "helloWorld".toPascalCase() }}
// "HelloWorld"
{{ $('HTTP Request').body.fieldName.toPascalCase() }}
// Convert field name to PascalCasetoWholeNumber()
Converts a string to an integer (whole number). For floats, truncates decimal part.
Returns: Number
Examples:
{{ "42".toWholeNumber() }}
// 42
{{ "3.9".toWholeNumber() }}
// 3 (truncates decimal)
{{ "-3.9".toWholeNumber() }}
// -3
{{ $('HTTP Request').body.count.toWholeNumber() }}
// Convert to integerurlEncode(entireString?: Boolean)
Encodes a string for use in URLs.
Parameters:
entireString(Boolean, optional): Whether to encode entire string
Returns: String
Examples:
{{ "hello world".urlEncode() }}
// "hello%20world"
{{ "name=Alice&age=25".urlEncode() }}
// "name%3DAlice%26age%3D25"
{{ $('Chat Trigger').message.urlEncode() }}
// Encode message for URLurlDecode(entireString?: Boolean)
Decodes a URL-encoded string.
Parameters:
entireString(Boolean, optional): Whether to decode entire string
Returns: String
Examples:
{{ "hello%20world".urlDecode() }}
// "hello world"
{{ "name%3DAlice%26age%3D25".urlDecode() }}
// "name=Alice&age=25"
{{ $('HTTP Request').body.encodedParam.urlDecode() }}
// Decode URL parameterEncodes a string for use in URLs.
Parameters:
entireString(Boolean, optional): Whether to encode entire string
Returns: String
Examples:
{{ "hello world".urlEncode() }}
// "hello%20world"
{{ "name=Alice&age=25".urlEncode() }}
// "name%3DAlice%26age%3D25"
{{ $('Chat Trigger').message.urlEncode() }}
// Encode message for URLStandard String Methods
In addition to custom methods, you can use standard JavaScript string methods:
// Case conversion
{{ "hello".toUpperCase() }} // "HELLO"
{{ "HELLO".toLowerCase() }} // "hello"
// Trim whitespace
{{ " hello ".trim() }} // "hello"
{{ "hello ".trimEnd() }} // "hello"
{{ " hello".trimStart() }} // "hello"
// String search
{{ "hello world".includes("world") }} // true
{{ "hello world".startsWith("hello") }} // true
{{ "hello world".endsWith("world") }} // true
{{ "hello world".indexOf("world") }} // 6
// String replacement
{{ "hello world".replace("world", "there") }} // "hello there"
{{ "aaa".replaceAll("a", "b") }} // "bbb"
// String split and join
{{ "a,b,c".split(",") }} // ["a", "b", "c"]
{{ ["a", "b", "c"].join("-") }} // "a-b-c"
// String extraction
{{ "hello".substring(0, 2) }} // "he"
{{ "hello".slice(1, 4) }} // "ell"
// Repeat
{{ "ha".repeat(3) }} // "hahaha"
// Length
{{ "hello".length }} // 5Use Cases
1. URL Processing
// Extract domain
{{ $('HTTP Request').body.url.extractDomain() }}
// Extract path
{{ $('HTTP Request').body.url.extractUrlPath() }}
// Validate URL
{{ $('HTTP Request').body.url.isUrl() }}
// URL encode/decode
{{ $('HTTP Request').body.query.urlEncode() }}
{{ $('HTTP Request').body.encodedQuery.urlDecode() }}2. Data Validation
// Validate email
{{ $('HTTP Request').body.email.isEmail() }}
// Validate domain
{{ $('HTTP Request').body.domain.isDomain() }}
// Validate number
{{ $('Chat Trigger').message.isNumeric() }}
// Check if empty
{{ $('Chat Trigger').message.isEmpty() }}3. Data Extraction
// Extract email
{{ $('Chat Trigger').message.extractEmail() }}
// Extract URL
{{ $('Chat Trigger').message.extractUrl() }}
// Extract domain
{{ $('Chat Trigger').message.extractDomain() }}4. Encoding/Decoding
// Base64 encode
{{ $('HTTP Request').body.data.base64Encode() }}
// Base64 decode
{{ $('HTTP Request').body.encodedData.base64Decode() }}
// JSON parse
{{ $('HTTP Request').body.jsonString.parseJson() }}5. Formatting
// Sentence case
{{ $('Chat Trigger').message.toSentenceCase() }}
// Snake case
{{ $('HTTP Request').body.fieldName.toSnakeCase() }}
// Kebab case
{{ $('HTTP Request').body.fieldName.toKebabCase() }}
// Camel case
{{ $('HTTP Request').body.fieldName.toCamelCase() }}
// Pascal case
{{ $('HTTP Request').body.fieldName.toPascalCase() }}
// Remove tags
{{ $('HTTP Request').body.html.removeTags() }}
// Remove Markdown
{{ $('HTTP Request').body.markdown.removeMarkdown() }}6. Type Conversion
// Convert to number
{{ $('Chat Trigger').message.toInt() }}
{{ $('Chat Trigger').message.toFloat() }}
// Convert to boolean
{{ $('HTTP Request').body.flag.toBoolean() }}7. Hashing
// MD5 hash
{{ $('Chat Trigger').message.hash() }}
// SHA-256 hash
{{ $('Chat Trigger').message.hash("sha256") }}Method Chaining
String methods can be chained:
// Extract, format, convert
{{ $('Chat Trigger').message
.trim()
.toLowerCase()
.toSentenceCase() }}
// Clean HTML and extract content
{{ $('HTTP Request').body.html
.removeTags()
.trim() }}
// URL processing chain
{{ $('HTTP Request').body.url
.extractDomain()
.toLowerCase() }}Best Practices
1. Validate Before Processing
// Validate email format before using
{{ $('HTTP Request').body.email.isEmail()
? $('HTTP Request').body.email.toLowerCase()
: 'invalid@example.com' }}2. Handle Potentially Empty Strings
// Check if empty
{{ $('Chat Trigger').message.isNotEmpty()
? $('Chat Trigger').message
: 'No message provided' }}3. Combine Multiple Methods
// Clean and format user input
{{ $('Chat Trigger').message
.trim()
.removeTags()
.toSentenceCase() }}4. Safely Parse JSON
// Safely parse in Code node
try {
const data = $('HTTP Request').body.jsonString.parseJson();
return data;
} catch (e) {
return { error: 'Invalid JSON' };
}