---
title: btoa
summary: The btoa() method creates a Base64-encoded ASCII string from a binary string (i.e., a string in which each character in the string is treated as a byte of binary data).
url: https://www.fastly.com/documentation/reference/compute/sdks/javascript/js-compute/globals/fn.btoa/
---

**Kind:** Function  
**Module:** [globals](https://www.fastly.com/documentation/reference/compute/sdks/javascript/js-compute/globals/)  
**Package:** @fastly/js-compute 4.0.1  
**Source:** https://github.com/fastly/js-compute-runtime/blob/70cf30af4e657879b2d1e7eafab880e39e3a3f7d/types/globals.d.ts#L2118

```javascript
btoa(data: string): string
```

The btoa() method creates a Base64-encoded ASCII string from a binary string (i.e., a string in which each character in the string is treated as a byte of binary data).

**See also**

- [btoa on MDN](https://developer.mozilla.org/en-US/docs/Web/API/btoa)

**Parameters**

- `data`: `string` — The binary string to encode.

**Returns**

`string`

An ASCII string containing the Base64 representation of `data`.
