aboutsummaryrefslogtreecommitdiff
path: root/docs/guides/util/base64.md
blob: bbc8f090639646d20ecf7eaa8f9968014b21c509 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
---
name: Encode and decode base64 strings
---

Bun implements the Web-standard [`atob`](https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/atob) and [`btoa`](https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/btoa) functions for encoding and decoding base64 strings.

```ts
const data = "hello world";
const encoded = btoa(data); // => "aGVsbG8gd29ybGQ="
const decoded = atob(encoded); // => "hello world"
```

---

See [Docs > Web APIs](/docs/runtime/web-apis) for a complete breakdown of the Web APIs implemented in Bun.