aboutsummaryrefslogtreecommitdiff
path: root/docs/guides/util/base64.md
blob: 06003f06225063fc2af5f29dac448157c21f0440 (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 > API > Hashing](/docs/api/hashing#bun-password) for complete documentation.