---
title: "BIT_LENGTH"
description: "The BIT_LENGTH SQL function gets the number of bits needed to represent a value."
language: en
source_language: en
translation_state: complete
canonical: https://documentation.invantive.eu/en/docs/invantive-universalsql/grammar/sql-functions/bit-length
original: https://documentation.invantive.eu/en/docs/invantive-universalsql/grammar/sql-functions/bit-length
updated: 2026-08-09T00:00:00Z
license: https://documentation.invantive.eu/en/
---

## Syntax
```mermaid
%%{init: {
  'theme': 'base',
  'flowchart': { 'padding': '7', 'nodeSpacing': '20', 'rankSpacing': '20' },
  'themeVariables': {
    'fontSize': '11px',
    'fontFamily': 'Arial'
  }
}}%%
flowchart LR
    Start((START)) --> BIT_LENGTH[BIT_LENGTH]:::quoted
    BIT_LENGTH --> End((END))
```

## Purpose
The `BIT_LENGTH` SQL function gets the number of bits needed to represent a value. For a `blob`, this is the number of bits for the bytes of the `blob`. For all other data types, the value is first converted to a text and then the number of bits of the UTF8 representation is determined.

Parameters:
- Value (`ANY`): value to determine length in bits for.

Returns: number of bits needed to represent the value as `int32`.

## Examples
`BIT_LENGTH` retrieves the length in bit of a two-byte `blob`:
```sql
select bit_length(base64_decode('aGk='))

--------
16
```
`BIT_LENGTH` retrieves the length in bit of the UTF8 representation of a three-character text:
```sql
select bit_length('abc')

--------
24
```