> ## Documentation Index
> Fetch the complete documentation index at: https://bun.zhcndoc.com/llms.txt
> Use this file to discover all available pages before exploring further.

# 编码和解码 base64 字符串

Bun 实现了 Web 标准的 [`atob`](https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/atob) 和 [`btoa`](https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/btoa) 函数，用于编码和解码 base64 字符串。

```ts theme={"theme":{"light":"github-light","dark":"dracula"}}
const data = "hello world";
const encoded = btoa(data); // => "aGVsbG8gd29ybGQ="
const decoded = atob(encoded); // => "hello world"
```

***

请参见 [文档 > Web API](/runtime/web-apis)，了解 Bun 实现的 Web API 完整细节。
