---
url: 'https://adk.nht.io/api/@nhtio/adk/common/functions/encodeBase64.md'
---

# Function: encodeBase64()

```ts
function encodeBase64(bytes: Uint8Array): string;
```

Defined in: [src/lib/helpers/base64.ts:33](https://github.com/NHTIO/ADK/blob/v1.20260713.1/src/src/lib/helpers/base64.ts#L33)

Encode a `Uint8Array` as a base64 string.

## Parameters

| Parameter | Type         | Description           |
| --------- | ------------ | --------------------- |
| `bytes`   | `Uint8Array` | The buffer to encode. |

## Returns

`string`

The base64 representation.

## Remarks

Prefers `Buffer.from(bytes).toString('base64')` when `globalThis.Buffer` exists; otherwise
chunk-encodes through `btoa` with a `0x8000`-byte window to avoid `Maximum call stack size exceeded`
on large buffers.
