> ## Documentation Index
> Fetch the complete documentation index at: https://firebolt-aggregate-helm-docs-pr-38.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

> Reference material for LENGTH function

# LENGTH

Calculates the length of the input string.

For `TEXT`, `LENGTH` returns the number of characters (Unicode code points), not the number of bytes. A character whose UTF-8 encoding uses more than one byte still counts as one. For `BYTEA`, `LENGTH` returns the number of bytes. To count bytes in a `TEXT` value, use [OCTET\_LENGTH](/reference-sql/functions-reference/string/octet_length).

`CHAR_LENGTH` and `CHARACTER_LENGTH` are synonyms for `LENGTH` on `TEXT`.

When used with an array argument, `LENGTH` is a synonym for [ARRAY\_LENGTH](/reference-sql/functions-reference/array/array-length)

## Syntax

```sql theme={"theme":{"light":"css-variables","dark":"css-variables"}}
LENGTH(<expression>)
```

## Parameters

| Parameter      | Description                                               | Supported input types                                                                                    |
| :------------- | :-------------------------------------------------------- | :------------------------------------------------------------------------------------------------------- |
| `<expression>` | The string or binary data for which to return the length. | `TEXT`, `BYTEA`. For `ARRAY`, see [ARRAY\_LENGTH](/reference-sql/functions-reference/array/array-length) |

## Return Type

`INTEGER`

## Example

Use the `LENGTH` to find the length of any string, such as:

<div className="query-window">
  ```
  SELECT LENGTH('The Accelerator Cup');
  ```

  | length <span>int</span> |
  | :---------------------- |
  | 19                      |

  <p><span>Rows: 1</span><span>Execution time: 6.03ms</span></p>
</div>

Spaces are included in the calculation of the total length of the string.

Because `LENGTH` counts characters rather than bytes, a multi-byte character counts as one. The character `🔥` is a single character encoded as four bytes (`0xF0 0x9F 0x94 0xA5`) in UTF-8:

<div className="query-window">
  ```
  SELECT LENGTH('🔥'), OCTET_LENGTH('🔥');
  ```

  | length <span>int</span> | octet\_length <span>int</span> |
  | :---------------------- | :----------------------------- |
  | 1                       | 4                              |

  <p><span>Rows: 1</span><span>Execution time: 5.44ms</span></p>
</div>

`LENGTH` returns 1 for the single character, while `OCTET_LENGTH` returns 4 because its UTF-8 encoding uses four bytes.
