# octet_length

> 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: octet_length
latest-operator-version: v26.2.4
latest-console-tag: v3.12.0
latest-connect-version: 4.113.0
latest-redpanda-tag: v26.2.4
docname: sql/sql-functions/string-functions/octet-length
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/octet-length.adoc
page-edit-url: https://github.com/redpanda-data/cloud-docs/edit/main/modules/reference/pages/sql/sql-functions/string-functions/octet-length.adoc
description: The `octet_length()` function returns the number of bytes in a binary value.
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/octet-length.md -->

The `octet_length()` function returns the number of bytes in a binary ([`bytea`](https://docs.redpanda.com/cloud-data-platform/reference/sql/sql-data-types/bytea/)) value. See also [`length()`](https://docs.redpanda.com/cloud-data-platform/reference/sql/sql-functions/string-functions/length/) to find the number of characters in a text string.

## [](#syntax)Syntax

```sql
OCTET_LENGTH(data)
```

## [](#arguments)Arguments

-   `data`: A `bytea` value.


## [](#return-type)Return type

`int`

## [](#examples)Examples

### [](#basic-usage)Basic usage

```sql
SELECT OCTET_LENGTH('\xdeadbeef'::bytea);
```

```sql
 octet_length
--------------
            4
(1 row)
```

### [](#empty-value)Empty value

```sql
SELECT OCTET_LENGTH(''::bytea);
```

```sql
 octet_length
--------------
            0
(1 row)
```