Skip to main content
Version: 4.0.0

Text Formatter

Text Formatter Block

The Text Formatter block provides a set of handy operations for string manipulation. All of the operations return a JSON with the result using the key value. The available options are:

Encode/Decode (Action)

Encode or decode a string using UTF-8, Hex, or Base64 encoding.

  • Input: String or variable to encode/decode
  • To Encoding: Encoding type (UTF-8, Hex, or Base64)

Example Input:

"Hello world!"

To Encoding:

"Base64"

Example Output:

JSON
{
"value": "SGVsbG8gd29ybGQh"
}

Include

Determine whether one string can be found within another string.

  • Input: String or variable to search within
  • Text: Text or variable to search for

Example Input:

"This is a sample text."

Text:

"sample"

Example Output:

JSON
{
"value": true
}

URL Encode/Decode

URL encode or decode a string.

  • Input: String or variable to encode/decode, usually a URL with characters in query params that need to be encoded
  • Operation: Encode or Decode

Example Input:

"https://example.com/search?q=hello world"

Operation:

"Encode"

Example Output:

JSON
{
"value": "https%3A%2F%2Fexample.com%2Fsearch%3Fq%3Dhello%2520world"
}

Upper Case

Convert all characters in a string to uppercase.

  • Input: String or variable to convert

Example Input:

"hello world"

Example Output:

JSON
{
"value": "HELLO WORLD"
}

Lower Case

Convert all characters in a string to lowercase.

  • Input: String or variable to convert

Example Input:

"HELLO WORLD"

Example Output:

JSON
{
"value": "hello world"
}

Random Text Generator

Randomly generate a 22-character long text.

Example Output:

JSON
{
"value": "aBcDeFgHiJkLmNoPqRsTuVw"
}

Regex Fetch

Fetch data from the input using regular expressions.

  • Input: String or variable to perform regex on
  • Regular Expression: Standard regex syntax

Example Input:

"The price is $42.50"

Regular Expression:

"\\$[0-9]+\\.[0-9]{2}"

Example Output:

JSON
{
"value": true
}

Split

Split text into a list.

  • Input: String or variable to split
  • Delimiter: Character to split on

Example Input:

"value1,value2,value3"

Delimiter:

","

Example Output:

JSON
{
"value": ["value1", "value2", "value3"]
}

Join

Join a list into a single line of text.

Input: Pieces of data to join from the data picker

Separator: Character to place between the concatenated parts

Example Input:

JSON
["John", "Doe"]

Separator:

JSON
" "

Example Output:

JSON
{
"value": "John Doe"
}

Slice from Start

Slice a string from a specified start index.

Input: String or variable to slice

Start Index: Index at which to start the slice

Example Input:

JSON
"Hello world!"

Start Index:

JSON
6

Example Output:

JSON
{
"value": "world!"
}

Slice from End

Slice a specified number of characters from the end of a string.

Input: String or variable to slice

Number of Characters: Number of characters to remove from the end

Example Input:

JSON
"Hello world!"

Number of Characters:

JSON
6

Example Output:

JSON
{
"value": "Hello"
}

Truncate

Convert a decimal number to a whole number.

Input: Decimal number or variable to truncate

Example Input:

JSON
22.22

Example Output:

JSON
{
"value": 22
}

What’s Next

After you've finished using the Text Formatter block, you can explore other utility blocks provided by Alloy. These utility blocks range from encryption and decryption utilities, list operations, data transformation, and more. You can also start to build complex workflows by combining different blocks according to your business requirements.