# JSONata $base64decode does not support UTF8 strings

**URL:** <https://discourse.nodered.org/t/jsonata-base64decode-does-not-support-utf8-strings/101146>\
**Category:** General\
**Tags:** jsonata, bug\
**Created:** [28 May 2026 06:04 UTC](https://discourse.nodered.org/t/jsonata-base64decode-does-not-support-utf8-strings/101146 "2026-05-28T06:04:12Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![gregorius](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gregorius/32/73816_2.png) [@gregorius](https://discourse.nodered.org/u/gregorius)\
**Post date:** [28 May 2026 06:04 UTC](https://discourse.nodered.org/t/jsonata-base64decode-does-not-support-utf8-strings/101146/1 "2026-05-28T06:04:12Z")

</div>

Hi There,

Taking this string `Teiüäösß utf8 fïléñámê.m4a`, encode as base64[1]: `echo "Teiüäösß utf8 fïléñámê.m4a" | base64` and get this string `VGVpdcyIYcyIb8yIc8OfIHV0ZjggZmnMiGxlzIFuzINhzIFtZcyCLm00YQo=`

If I take the b64 string and push it through the JSONata `$base64decode(..)` function, I get `TeiuÌaÌoÌsÃ utf8 fiÌleÌnÌaÌmeÌ.m4a`.

Demonstrated by this flow:

```flows
[{"id":"9a543998ea22e0eb","type":"inject","z":"6378c786ada4ddc2","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"VGVpdcyIYcyIb8yIc8OfIHV0ZjggZmnMiGxlzIFuzINhzIFtZcyCLm00YQ==","payloadType":"str","x":500,"y":430,"wires":[["a56ae1312fde1caf"]]},{"id":"a56ae1312fde1caf","type":"change","z":"6378c786ada4ddc2","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"$base64decode($$.payload)","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":728,"y":477,"wires":[["f98636d0205a090e"]]},{"id":"f98636d0205a090e","type":"debug","z":"6378c786ada4ddc2","name":"debug 1","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1016,"y":489,"wires":[]}]

```

Tested with NR 4.0.9

Work around is to use the ~~JS code~~ NodeJS code[2] in a function node instead of using $base64decode in a change node.

[1]: can also be done using the following JS code (gives the same b64 string):

```js
    const blobToBase64 = (blob) => {
        return new Promise((resolve, reject) => {
            const reader = new FileReader();

            reader.onloadend = () => {
                const base64String = reader.result.split(',')[1]; // Remove the prefix
                resolve(base64String);
            };

            reader.onerror = reject;
            reader.readAsDataURL(blob); // Read the Blob as a data URL
        });
    };

    blobToBase64(new Blob(["Teiüäösß utf8 fïléñámê.m4a"], {type: 'text/plain'})).then( base64 => console.log(base64))

```

[2]: NodeJS function code

```auto
msg.payload = Buffer.from(msg.payload, "base64").toString("utf-8").trim()
return msg

```

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [28 May 2026 07:47 UTC](https://discourse.nodered.org/t/jsonata-base64decode-does-not-support-utf8-strings/101146/2 "2026-05-28T07:47:09Z")

</div>

Or [3] you could use [node-red-node-base64 (node) - Node-RED](https://flows.nodered.org/node/node-red-node-base64).

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [28 May 2026 08:31 UTC](https://discourse.nodered.org/t/jsonata-base64decode-does-not-support-utf8-strings/101146/3 "2026-05-28T08:31:39Z")

</div>

Appears to be a bug in jsonata - not something we fix in Node-RED itself.

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/e/a/eac5e4512359c00541ed7a5af7a8dd34ec016f16.png)

---

<div class="post-metadata">

**Author:** ![gregorius](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gregorius/32/73816_2.png) [@gregorius](https://discourse.nodered.org/u/gregorius)\
**Post date:** [28 May 2026 15:34 UTC](https://discourse.nodered.org/t/jsonata-base64decode-does-not-support-utf8-strings/101146/4 "2026-05-28T15:34:52Z")

</div>

> [@knolleary](#):
>
> not something we fix in Node-RED itself.

To avoid future confusion, one could remove the two functions from NR's JSONata support, i.e., that `$base64encode` and `$base64decode` cannot be accessed from within NR.

Technically speaking then there is something that NR could do but probably shouldn't do because of backward compatibility and also it does not seem to have bothered anyone until now anyway.

So this becomes more of an FYI for future "end" users.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [27 July 2026 15:35 UTC](https://discourse.nodered.org/t/jsonata-base64decode-does-not-support-utf8-strings/101146/5 "2026-07-27T15:35:25Z")

</div>

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
