mirror of
https://github.com/oven-sh/bun
synced 2026-02-02 15:08:46 +00:00
18 lines
611 B
Plaintext
18 lines
611 B
Plaintext
---
|
|
title: Encode and decode base64 strings
|
|
sidebarTitle: Base64 encoding
|
|
mode: center
|
|
---
|
|
|
|
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](/runtime/web-apis) for a complete breakdown of the Web APIs implemented in Bun.
|