---
title: "base64encode Formula Function: Encode Text as Base64 in Nodinite Search Fields"
description: The base64encode Formula function encodes text from the message body, a context property, or another function as base64, with an optional input encoding such as UTF-8 or ISO-8859-1.
---

# :fa-function: 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.

![Encode the order id and the customer name of an Order-to-Cash event as base64 with base64encode, animated walkthrough (7.12)][hero]  
*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.*  

## :fa-code: Syntax

```text
base64encode(content [, 'input encoding'])
```

### 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

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.

## :fa-list-ol: Examples

### Example 1: Encode the message body

#### Input

```text
Nodinite
```

#### Formula

```text
base64encode(body)
```

#### Result

```text
Tm9kaW5pdGU=
```

![Test Expression tab: base64encode(body) encodes the message body Nodinite to Tm9kaW5pdGU= (7.12)][1]  
*Plain ASCII text gives the same base64 result in UTF-8 and ISO-8859-1.*  

### Example 2: Encode text as ISO-8859-1

#### Input

```text
Skellefteå
```

#### Formula

```text
base64encode(body, 'iso-8859-1')
```

#### Result

```text
U2tlbGxlZnRl5Q==
```

![Test Expression tab: base64encode(body, 'iso-8859-1') encodes Skellefteå to U2tlbGxlZnRl5Q== (7.12)][2]  
*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

#### Input

|Key|Value|
|---|---|
|`id`|`Simple`|

#### Formula

```text
base64encode(context('id'))
```

#### Result

```text
U2ltcGxl
```

![Test Expression tab: base64encode(context('id')) encodes the context value Simple to U2ltcGxl (7.12)][3]  
*The value of the context property `id` is encoded; the message body isn't used.*  

### Example 4: Encode several values from a JSON body

#### Input

```json
[
    { "name": "Hello" },
    { "name": "World" }
]
```

#### Formula

```text
base64encode(jsonPath('$..name',body))
```

#### Result

```text
SGVsbG8=
V29ybGQ=
```

![Test Expression tab: base64encode of a jsonPath result returns SGVsbG8= and V29ybGQ= (7.12)][4]  
*`jsonPath` returns two values, and `base64encode` encodes each one: two unique matches.*  

## :fa-circle-info: Notes

* 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](https://learn.microsoft.com/en-us/dotnet/api/system.text.encoding?view=net-6.0#list-of-encodings)<sup>:fa-arrow-up-right-from-square:</sup>.

## :fa-hand-point-right: Next Steps

* :fa-magnifying-glass-plus: [Add or manage Search Field][]  
* :fa-flask: [Test Your Expression][]  
* :fa-hard-drive: [Add or manage Log View][]  

## :fa-link-horizontal: Related Topics

* :fa-unlock: [base64decode][]  
* :fa-language: [convert][]  
* :fa-arrow-down-a-z: [toLowerCase][]  
* :fa-arrow-up-a-z: [toUpperCase][]  
* :fa-function: [Formula][]  
* :fa-scroll: [Formula language rules][]  
* :fa-puzzle-piece: [Search Field Expressions][]  
* :fa-language: [Character Encoding][]  

[1]:{ndm}/Documentation%20Pictures/IM/WebClient/Admin/Log/Search%20Fields/Plugins/Formula/Convert/base64encode-message-body.png
[2]:{ndm}/Documentation%20Pictures/IM/WebClient/Admin/Log/Search%20Fields/Plugins/Formula/Convert/base64encode-message-body-withencoding.png
[3]:{ndm}/Documentation%20Pictures/IM/WebClient/Admin/Log/Search%20Fields/Plugins/Formula/Convert/base64encode-messageContext.png
[4]:{ndm}/Documentation%20Pictures/IM/WebClient/Admin/Log/Search%20Fields/Plugins/Formula/Convert/base64encode_functionAsContent.png

[Add or manage Log View]:{ndr}/Administration/1.%20Log%20Management/1.%20Log%20Views/Features/Add%20or%20Manage%20Log%20View.md
[Add or manage Search Field]:{ndr}/Administration/1.%20Log%20Management/2.%20Search%20Fields/Features/Add%20or%20manage%20Search%20Field.md
[base64decode]:{ndr}/Administration/1.%20Log%20Management/2.%20Search%20Fields/Features/Search%20Field%20Expressions/Formula/Convert/base64decode.md
[body]:{ndr}/Administration/1.%20Log%20Management/2.%20Search%20Fields/Features/Search%20Field%20Expressions/Formula/Source/body.md
[Character Encoding]:{ndr}/Core%20Services/Log%20Event/Features/Character%20Encoding.md
[Context]:{ndr}/Administration/1.%20Log%20Management/2.%20Search%20Fields/Features/Search%20Field%20Expressions/Formula/Source/context.md
[convert]:{ndr}/Administration/1.%20Log%20Management/2.%20Search%20Fields/Features/Search%20Field%20Expressions/Formula/Convert/convert.md
[Formula]:{ndr}/Administration/1.%20Log%20Management/2.%20Search%20Fields/Features/Search%20Field%20Expressions/Formula/Overview.md
[Formula language rules]:{ndr}/Administration/1.%20Log%20Management/2.%20Search%20Fields/Features/Search%20Field%20Expressions/Formula/Overview.md#fa-scroll-formula-language-rules
[hero]:{ndm}/Documentation%20Pictures/IM/WebClient/Admin/Log/Search%20Fields/Plugins/Formula/Convert/Formula_Base64Encode.gif
[jsonPath]:{ndr}/Administration/1.%20Log%20Management/2.%20Search%20Fields/Features/Search%20Field%20Expressions/Formula/Extract/jsonPath.md
[Order-to-Cash demo]:{ndr}/Repository%20Model/BPMs/Examples/Order-to-Cash/Generate-O2C-Demo-Data.md
[Search Field]:{ndr}/Administration/1.%20Log%20Management/2.%20Search%20Fields/Features/What%20is%20a%20Search%20Field.md
[Search Field Expressions]:{ndr}/Administration/1.%20Log%20Management/2.%20Search%20Fields/Features/Search%20Field%20Expressions/Overview.md
[Test Your Expression]:{ndr}/Administration/1.%20Log%20Management/2.%20Search%20Fields/Features/Add%20or%20manage%20Search%20Field.md#test-your-expression
[toLowerCase]:{ndr}/Administration/1.%20Log%20Management/2.%20Search%20Fields/Features/Search%20Field%20Expressions/Formula/Convert/toLowerCase.md
[toUpperCase]:{ndr}/Administration/1.%20Log%20Management/2.%20Search%20Fields/Features/Search%20Field%20Expressions/Formula/Convert/toUpperCase.md