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

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

## :fa-code: 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, …*.

## :fa-list-ol: 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.*  

## :fa-circle-info: 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>: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-lock: [base64encode][]  
* :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/base64decode-messageBody.png
[3]:{ndm}/Documentation%20Pictures/IM/WebClient/Admin/Log/Search%20Fields/Plugins/Formula/Convert/base64decode_messagecontext_simplecontext.png
[4]:{ndm}/Documentation%20Pictures/IM/WebClient/Admin/Log/Search%20Fields/Plugins/Formula/Convert/base64decode-context.png
[5]:{ndm}/Documentation%20Pictures/IM/WebClient/Admin/Log/Search%20Fields/Plugins/Formula/Convert/base64decode-messageBody-nested.png
[6]:{ndm}/Documentation%20Pictures/IM/WebClient/Admin/Log/Search%20Fields/Plugins/Formula/Formula_Base64Decode.gif

[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
[Base64 Decode into an encoding]:{ndr}/Core%20Services/Log%20Event/Features/Character%20Encoding.md#fa-file-zipper-base64-decode-into-an-encoding
[base64encode]:{ndr}/Administration/1.%20Log%20Management/2.%20Search%20Fields/Features/Search%20Field%20Expressions/Formula/Convert/base64encode.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
[ex3]:{ndm}/Documentation%20Pictures/IM/WebClient/Admin/Log/Search%20Fields/Plugins/Formula/Convert/base64decode_example3.png
[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
[jsonPath]:{ndr}/Administration/1.%20Log%20Management/2.%20Search%20Fields/Features/Search%20Field%20Expressions/Formula/Extract/jsonPath.md
[Logging Service]:{ndr}/Core%20Services/Logging%20Service/Overview.md
[Message Types]:{ndr}/Repository%20Model/Message%20Types/Overview.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