---
title: "base64decode Formula Function: Decode Base64 in Nodinite Search Fields"
description: The base64decode Formula function decodes base64 text from the message body, a context property, or another function into readable text, with an optional source encoding such as UTF-8 or ISO-8859-1.
---

# <i class="fal fa-function" aria-hidden="true"></i> Formula - base64decode

The `base64decode` [Formula][] function decodes base64 text and returns the original text, read with UTF-8 or with the source encoding you name.

![Decode the base64 content of a Logic App request with base64decode and jsonPath, animated walkthrough (7.12)][6]  
*Animated walkthrough: a Logic App request carries the Order Entry XML of the [Order-to-Cash demo][] as base64 in `$content`; `base64decode(jsonPath('$content', body))` returns the decoded XML.*  

## <i class="fal fa-code" aria-hidden="true"></i> Syntax

```text
base64decode(content [, 'source encoding'])
```

### Parameters

|Parameter|Required|Description|
|---|---|---|
|`content`|Yes|The base64 text to decode: [body][], [context][], or the result of another function, such as [jsonPath][].|
|`'source encoding'`|No|The character encoding of the decoded bytes, such as `'UTF-8'` or `'iso-8859-1'`. Use the encoding the sender used before it encoded the text. Without it, the bytes are read as UTF-8.|

### Returns

The decoded text. When the content holds several values, for example from `jsonPath`, each value is decoded and returned as its own [Search Field][] value. When the content has no value, such as a missing context key, nothing is returned. Content that isn't base64 returns no value either, and the test bench shows the .NET message *The input is not a valid Base-64 string as it contains a non-base 64 character, …*.

## <i class="fal fa-list-ol" aria-hidden="true"></i> Examples

### Example 1: Decode a base64 message body

#### Input

```text
bm9kaW5pdGU=
```

#### Formula

```text
base64decode(body)
```

#### Result

```text
nodinite
```

![Test Expression tab: base64decode(body) decodes the message body bm9kaW5pdGU= to nodinite (7.12)][1]  
*The base64 body decodes to `nodinite` with the default UTF-8 encoding.*  

### Example 2: Decode UTF-8 text with a special character

#### Input

```text
U2tlbGxlZnRlw6U=
```

#### Formula

```text
base64decode(body, 'UTF-8')
```

#### Result

```text
Skellefteå
```

![Test Expression tab: base64decode(body, 'UTF-8') decodes U2tlbGxlZnRlw6U= to Skellefteå (7.12)][3]  
*The two UTF-8 bytes for `å` decode correctly because the source encoding matches.*  

### Example 3: Decode ISO-8859-1 text

The same word, encoded from ISO-8859-1 bytes, is a different base64 string. Name the encoding to read the bytes correctly.

#### Input

```text
U2tlbGxlZnRl5Q==
```

#### Formula

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

#### Result

```text
Skellefteå
```

![Test Expression tab: base64decode(body, 'iso-8859-1') decodes U2tlbGxlZnRl5Q== to Skellefteå (7.12)][ex3]  
*In ISO-8859-1, `å` is the single byte `E5`, so the base64 text differs from Example 2 but decodes to the same word.*  

### Example 4: Decode a context property

#### Input

|Key|Value|
|---|---|
|`id`|`bm9kaW5pdGU=`|

#### Formula

```text
base64decode(context('id'))
```

#### Result

```text
nodinite
```

![Test Expression tab: base64decode(context('id')) decodes the context value bm9kaW5pdGU= to nodinite (7.12)][4]  
*The value of the context property `id` is decoded; the message body isn't used.*  

### Example 5: Decode several values from a JSON body

#### Input

```json
[ { "name": "YXdlc29tZQ==" }, { "name": "ZnVuY3Rpb24=" } ]
```

#### Formula

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

#### Result

```text
awesome
function
```

![Test Expression tab: base64decode of a jsonPath result returns two decoded values, awesome and function (7.12)][5]  
*`jsonPath` returns two base64 values, and `base64decode` decodes each one: two unique matches.*  

## <i class="fal fa-circle-info" aria-hidden="true"></i> Notes

* The source encoding must match the bytes inside the base64 text. Reading ISO-8859-1 bytes as UTF-8 turns characters such as `å` into replacement characters.
* When every message of a [Message Type][Message Types] is logged as base64, you can set its encoding to a **Base64 Decode into …** option instead. The [Logging Service][] then decodes the body before any Search Field Expression runs, so plain [body][] is already text; see [Base64 Decode into an encoding][].
* 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><i class="fal fa-arrow-up-right-from-square" aria-hidden="true"></i></sup>.

## <i class="fal fa-hand-point-right" aria-hidden="true"></i> Next Steps

* <i class="fal fa-magnifying-glass-plus" aria-hidden="true"></i> [Add or manage Search Field][]  
* <i class="fal fa-flask" aria-hidden="true"></i> [Test Your Expression][]  
* <i class="fal fa-hard-drive" aria-hidden="true"></i> [Add or manage Log View][]  

## <i class="fal fa-link-horizontal" aria-hidden="true"></i> Related Topics

* <i class="fal fa-lock" aria-hidden="true"></i> [base64encode][]  
* <i class="fal fa-language" aria-hidden="true"></i> [convert][]  
* <i class="fal fa-arrow-down-a-z" aria-hidden="true"></i> [toLowerCase][]  
* <i class="fal fa-arrow-up-a-z" aria-hidden="true"></i> [toUpperCase][]  
* <i class="fal fa-function" aria-hidden="true"></i> [Formula][]  
* <i class="fal fa-scroll" aria-hidden="true"></i> [Formula language rules][]  
* <i class="fal fa-puzzle-piece" aria-hidden="true"></i> [Search Field Expressions][]  
* <i class="fal fa-language" aria-hidden="true"></i> [Character Encoding][]  

[1]:https://docs.nodinite.com/media/Documentation%20Pictures/IM/WebClient/Admin/Log/Search%20Fields/Plugins/Formula/Convert/base64decode-messageBody.png
[3]:https://docs.nodinite.com/media/Documentation%20Pictures/IM/WebClient/Admin/Log/Search%20Fields/Plugins/Formula/Convert/base64decode_messagecontext_simplecontext.png
[4]:https://docs.nodinite.com/media/Documentation%20Pictures/IM/WebClient/Admin/Log/Search%20Fields/Plugins/Formula/Convert/base64decode-context.png
[5]:https://docs.nodinite.com/media/Documentation%20Pictures/IM/WebClient/Admin/Log/Search%20Fields/Plugins/Formula/Convert/base64decode-messageBody-nested.png
[6]:https://docs.nodinite.com/media/Documentation%20Pictures/IM/WebClient/Admin/Log/Search%20Fields/Plugins/Formula/Formula_Base64Decode.gif

[Add or manage Log View]:https://docs.nodinite.com/administration/log-management/log-views/features/add-or-manage-log-view/
[Add or manage Search Field]:https://docs.nodinite.com/administration/log-management/search-fields/features/add-or-manage-search-field/
[Base64 Decode into an encoding]:https://docs.nodinite.com/core-services/log-event/features/character-encoding/#fa-file-zipper-base64-decode-into-an-encoding
[base64encode]:https://docs.nodinite.com/administration/log-management/search-fields/features/search-field-expressions/formula/convert/base64encode/
[body]:https://docs.nodinite.com/administration/log-management/search-fields/features/search-field-expressions/formula/source/body/
[Character Encoding]:https://docs.nodinite.com/core-services/log-event/features/character-encoding/
[Context]:https://docs.nodinite.com/administration/log-management/search-fields/features/search-field-expressions/formula/source/context/
[convert]:https://docs.nodinite.com/administration/log-management/search-fields/features/search-field-expressions/formula/convert/convert/
[ex3]:https://docs.nodinite.com/media/Documentation%20Pictures/IM/WebClient/Admin/Log/Search%20Fields/Plugins/Formula/Convert/base64decode_example3.png
[Formula]:https://docs.nodinite.com/administration/log-management/search-fields/features/search-field-expressions/formula/overview/
[Formula language rules]:https://docs.nodinite.com/administration/log-management/search-fields/features/search-field-expressions/formula/overview/#fa-scroll-formula-language-rules
[jsonPath]:https://docs.nodinite.com/administration/log-management/search-fields/features/search-field-expressions/formula/extract/jsonpath/
[Logging Service]:https://docs.nodinite.com/core-services/logging-service/overview/
[Message Types]:https://docs.nodinite.com/repository-model/message-types/overview/
[Order-to-Cash demo]:https://docs.nodinite.com/repository-model/bpms/examples/order-to-cash/generate-o2c-demo-data/
[Search Field]:https://docs.nodinite.com/administration/log-management/search-fields/features/what-is-a-search-field/
[Search Field Expressions]:https://docs.nodinite.com/administration/log-management/search-fields/features/search-field-expressions/overview/
[Test Your Expression]:https://docs.nodinite.com/administration/log-management/search-fields/features/add-or-manage-search-field/#test-your-expression
[toLowerCase]:https://docs.nodinite.com/administration/log-management/search-fields/features/search-field-expressions/formula/convert/tolowercase/
[toUpperCase]:https://docs.nodinite.com/administration/log-management/search-fields/features/search-field-expressions/formula/convert/touppercase/