> For the complete documentation index, see [llms.txt](https://docs.pinot.apache.org/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.pinot.apache.org/release-1.3.0/configuration-reference/functions/base64.md).

# Base64

This section contains reference documentation for base64 encode and decode functions.

Encoding scheme follows [java.util.Base64.Encoder](https://docs.oracle.com/javase/8/docs/api/java/util/Base64.Encoder.html)

* `toBase64` returns Base64 encoded string of input binary data (`bytes` type).
* `fromBase64` returns binary data (represented as a Hex string) from Base64-encoded string.

## Signature

> toBase64(bytesCol)
>
> fromBase64(stringCol)

## Usage Examples

{% hint style="info" %}
For better readability, the following examples converts string `hello!` into BYTES using [toUtf8](https://docs.pinot.apache.org/configuration-reference/functions/utf8) function and converts the decoded BYTES into string using [fromUtf8](https://docs.pinot.apache.org/configuration-reference/functions/utf8).
{% endhint %}

```sql
SELECT toBase64(toUtf8('hello!')) AS encoded
FROM ignoreMe
```

| encoded  |
| -------- |
| aGVsbG8h |

```sql
SELECT fromUtf8(fromBase64('aGVsbG8h')) AS decoded
FROM ignoreMe
```

| decoded |
| ------- |
| hello!  |

{% hint style="info" %}
Note that without UTF8 string conversion, returned BYTES will be represented as a Hex string following Pinot's [BYTES column representation](https://docs.pinot.apache.org/users/user-guide-query/querying-pinot#bytes-column). See the example below.
{% endhint %}

```sql
SELECT fromBase64('aGVsbG8h') AS decoded
FROM ignoreMe
```

| decoded      |
| ------------ |
| 68656c6c6f21 |

{% hint style="warning" %}
Note that the following query will throw compilation error as string is not a valid input type for `toBase64`.
{% endhint %}

```sql
SELECT toBase64('hello!') AS encoded
FROM ignoreMe
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.pinot.apache.org/release-1.3.0/configuration-reference/functions/base64.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
