---
title: "base64"
description: "The base64 namespace — the engine's Luau API reference for base64."
section: "API Reference"
slug: "api-base64"
canonical: "https://origozero.ai/docs/api-base64"
updated: "2026-09-05T23:13:46.223733153+00:00"
tags: ["api", "reference"]
---

# base64

The `base64` namespace — 7 functions.

## globals/base64/decode {#globals-base64-decode}

```lua
base64.decode(text: string) -> (string?, string?)
```

Decode standard-alphabet base64 text back to the original binary string.

**Parameters**

- `text` `string` — Base64 text to decode.

**Returns** `(string?, string?)` decoded bytes on success, or (nil, errmsg).

```lua
local bytes = base64.decode(text)
```

## globals/base64/encode {#globals-base64-encode}

```lua
base64.encode(bytes: buffer | string) -> string
```

Encode a binary string to standard-alphabet (padded) base64 text.

**Parameters**

- `bytes` `buffer | string` — Binary bytes to encode.

**Returns** `string` — Base64 text.

```lua
local text = base64.encode(jpegBytes)
```

## modules/base64/README {#modules-base64-readme}

```lua
require("@builtin/modules/api/engine/base64") -- base64 (also available as global 'base64')
```

Base64 encode / decode between binary and text Luau strings (standard RFC 4648 alphabet, padded). Public Luau surface over the `__base64` Internal FFI namespace.

Usage: local base64 = require("@builtin/modules/api/engine/base64")
Also available as global: base64

## modules/base64/decode {#modules-base64-decode}

```lua
decode(text: string): (string?, string?)
```

Decode standard-alphabet base64 text back to the original binary string.

**Parameters**

- `text` `string` — Base64 text to decode.

```lua
local bytes = base64.decode(text)
```

## modules/base64/encode {#modules-base64-encode}

```lua
encode(bytes: buffer | string): string
```

Encode a binary string to standard-alphabet (padded) base64 text.

**Parameters**

- `bytes` `buffer | string` — Binary bytes to encode.

```lua
local text = base64.encode(jpegBytes)
```

## typed/builtin//modules/api/engine/base64/base64/decode {#typed-builtin-modules-api-engine-base64-base64-decode}

```lua
base64.decode(text: string) -> (string?, string?)
```

Decode standard-alphabet base64 text back to the original binary string.

**Parameters**

- `text` `string` — Base64 text to decode.

**Returns** `(string?, string?)` decoded bytes on success, or (nil, errmsg).

```lua
local bytes = base64.decode(text)
```

## typed/builtin//modules/api/engine/base64/base64/encode {#typed-builtin-modules-api-engine-base64-base64-encode}

```lua
base64.encode(bytes: buffer | string) -> string
```

Encode a binary string to standard-alphabet (padded) base64 text.

**Parameters**

- `bytes` `buffer | string` — Binary bytes to encode.

**Returns** `string` — Base64 text.

```lua
local text = base64.encode(jpegBytes)
```
