Formula - base64encode
Section titled “ Formula - base64encode”The base64encode Formula function returns the base64 representation of text, encoded to bytes with UTF-8 or with the input encoding you name.

Animated walkthrough: on the JSON Order Received event of order ORD-10005 in the Order-to-Cash demo, base64encode(jsonPath('$.orderId', body)) returns T1JELTEwMDA1, the UTF-8 bytes of ORD-10005. With the input encoding 'iso-8859-1', the customer name Tailspin Toys becomes VGFpbHNwaW4gVG95cw==; plain ASCII text gives the same result in UTF-8.
Syntax
Section titled “ Syntax”base64encode(content [, 'input encoding'])Parameters
Section titled “Parameters”| Parameter | Required | Description |
|---|---|---|
content |
Yes | The text to encode: body, context, or the result of another function, such as jsonPath. |
'input encoding' |
No | The character encoding used to turn the text into bytes before base64 encoding, such as 'UTF-8' or 'iso-8859-1'. Without it, UTF-8 is used. |
Returns
Section titled “Returns”The base64 text. When the content holds several values, for example from jsonPath, each value is encoded and returned as its own Search Field value. When the content has no value, nothing is returned.
Examples
Section titled “ Examples”Example 1: Encode the message body
Section titled “Example 1: Encode the message body”NodiniteFormula
Section titled “Formula”base64encode(body)Result
Section titled “Result”Tm9kaW5pdGU=
Plain ASCII text gives the same base64 result in UTF-8 and ISO-8859-1.
Example 2: Encode text as ISO-8859-1
Section titled “Example 2: Encode text as ISO-8859-1”SkellefteåFormula
Section titled “Formula”base64encode(body, 'iso-8859-1')Result
Section titled “Result”U2tlbGxlZnRl5Q==
With ISO-8859-1, å is the single byte E5. With the default UTF-8, the result is U2tlbGxlZnRlw6U= instead.
Example 3: Encode a context property
Section titled “Example 3: Encode a context property”| Key | Value |
|---|---|
id |
Simple |
Formula
Section titled “Formula”base64encode(context('id'))Result
Section titled “Result”U2ltcGxl
The value of the context property id is encoded; the message body isn't used.
Example 4: Encode several values from a JSON body
Section titled “Example 4: Encode several values from a JSON body”[ { "name": "Hello" }, { "name": "World" }]Formula
Section titled “Formula”base64encode(jsonPath('$..name',body))Result
Section titled “Result”SGVsbG8=V29ybGQ=
jsonPath returns two values, and base64encode encodes each one: two unique matches.
- Pick the input encoding the receiving system expects; to re-encode text without base64, use convert. Characters outside ASCII, such as
å,ö, andé, give different base64 results in UTF-8, ISO-8859-1, and Windows-1252. - Encoding names follow .NET; see the List of encodings.