# decode

> For the complete documentation index, see [llms.txt](https://docs.redpanda.com/llms.txt). Component-specific: [cloud-data-platform-full.txt](https://docs.redpanda.com/cloud-data-platform-full.txt)

---
title: decode
latest-operator-version: v26.2.4
latest-console-tag: v3.12.0
latest-connect-version: 4.113.1
latest-redpanda-tag: v26.2.4
docname: sql/sql-functions/string-functions/decode
page-component-name: cloud-data-platform
page-version: master
page-component-version: master
page-component-title: Cloud
page-relative-src-path: sql/sql-functions/string-functions/decode.adoc
page-edit-url: https://github.com/redpanda-data/cloud-docs/edit/main/modules/reference/pages/sql/sql-functions/string-functions/decode.adoc
description: The `decode()` function decodes text data into binary data using a specified format.
page-topic-type: reference
page-git-created-date: "2026-09-08"
page-git-modified-date: "2026-09-08"
---

<!-- Source: https://docs.redpanda.com/cloud-data-platform/reference/sql/sql-functions/string-functions/decode.md -->

The `decode()` function decodes text data into binary ([`bytea`](https://docs.redpanda.com/cloud-data-platform/reference/sql/sql-data-types/bytea/)) data using a specified format. It is the inverse of [`encode()`](https://docs.redpanda.com/cloud-data-platform/reference/sql/sql-functions/string-functions/encode/).

## [](#syntax)Syntax

The syntax of the `decode()` function is:

```sql
DECODE(string, format)
```

The `decode()` function requires two arguments:

-   `string`: The text value to decode.

-   `format`: The format that `string` is encoded in. Supported values are `hex`, `base64`, and `escape`.


## [](#examples)Examples

### [](#decode-a-hex-string)Decode a hex string

This example decodes a hexadecimal string back into binary data:

```sql
SELECT DECODE('deadbeef', 'hex');
```

```sql
+--------------+
| decode       |
+--------------+
| \xdeadbeef   |
+--------------+
```

### [](#decode-a-base64-string)Decode a base64 string

This example decodes a base64 string back into binary data:

```sql
SELECT DECODE('SGVsbG8=', 'base64');
```

```sql
+---------------+
| decode        |
+---------------+
| \x48656c6c6f  |
+---------------+
```