# base64 encode/decode in custom code step

**URL:** <https://community.hubspot.com/t/base64-encode-decode-in-custom-code-step/51266>\
**Category:** Data Hub\
**Tags:** workflows\
**Created:** [February 10, 2022, 6:23am UTC](https://community.hubspot.com/t/base64-encode-decode-in-custom-code-step/51266 "2022-02-10T06:23:37Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![WaydeChristie1](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/waydechristie1/32/10224_2.png) [@WaydeChristie1](https://community.hubspot.com/u/WaydeChristie1)\
**Post date:** [February 10, 2022, 6:23am UTC](https://community.hubspot.com/t/base64-encode-decode-in-custom-code-step/51266/1 "2022-02-10T06:23:37Z")

</div>

Hi folks,

Trying to base64 encode a string in a workflow custom code step but it looks like the Javascript functions btoa and aotb are not supported.

Does anyone know how I can achieve this?

Thanks in advance.

---

<div class="post-metadata">

**Author:** ![ChrisoKlepke](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/chrisoklepke/32/11213_2.png) [@ChrisoKlepke](https://community.hubspot.com/u/ChrisoKlepke)\
**Post date:** [March 3, 2022, 2:35pm UTC](https://community.hubspot.com/t/base64-encode-decode-in-custom-code-step/51266/2 "2022-03-03T14:35:01Z")

</div>

Hey @WaydeChristie1,

since the custom code actions came along, I dabble a bit with them in Python, but I’m not a dev. So, I don’t have any clue about JS and the methods you’re mentioning, buuuuuut… there is a module in the standard python library for this:

> **[base64 — Base16, Base32, Base64, Base85 Data Encodings](https://docs.python.org/3/library/base64.html)**
>
> Source code: Lib/base64.py This module provides functions for encoding binary data to printable ASCII characters and decoding such encodings back to binary data. This includes the encodings specifi...

Would this be an option to try? Looks promising if you’re only doing that, but of course if the rest of your custom code action is also JS this is nonsense.

Cheers,

Chriso

---

<div class="post-metadata">

**Author:** ![nikodev](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/nikodev/32/44733_2.png) [@nikodev](https://community.hubspot.com/u/nikodev)\
**Post date:** [May 12, 2022, 5:24pm UTC](https://community.hubspot.com/t/base64-encode-decode-in-custom-code-step/51266/3 "2022-05-12T17:24:31Z")

</div>

Hey there @WaydeChristie1,  
aotb and btoa have indeed been deprecated. The following would be how I’d go about the decoding/encoding process when working with base64:

```lia-code-sample
let base64Str = "aGVsbG8=" 
let binary = Buffer.from(base64Str, "base64")
let decoded = binary.toString() 
console.log(binary)
console.log("Decoded base64 result:", decoded)

-------------

let str = "Encode Example"
let binary2 = Buffer.from(str)
let base64Encoded = binary2.toString("base64")
console.log("Encoded base 64 result:", base64Encoded)

```

---

<div class="post-metadata">

**Author:** ![WaydeChristie1](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/waydechristie1/32/10224_2.png) [@WaydeChristie1](https://community.hubspot.com/u/WaydeChristie1)\
**Post date:** [May 12, 2022, 11:21pm UTC](https://community.hubspot.com/t/base64-encode-decode-in-custom-code-step/51266/4 "2022-05-12T23:21:28Z")

</div>

Thanks very much nikodev. This is exactly what I needed 👍

---

<div class="post-metadata">

**Author:** ![ASaiSB](https://avatars.discourse-cdn.com/v4/letter/a/ce73a5/32.png) [@ASaiSB](https://community.hubspot.com/u/ASaiSB)\
**Post date:** [April 7, 2026, 6:18am UTC](https://community.hubspot.com/t/base64-encode-decode-in-custom-code-step/51266/5 "2026-04-07T06:18:23Z")

</div>

Here is a visualizer tool that breaks the process of Base64 encoding down step by step:

> **[Base64 Encoding Visualizer](https://base64-encoding-simulator.onrender.com/)**
