Copy as Markdown[Open in ChatGPT](https://chatgpt.com/?q=Read%20https%3A%2F%2Fdocs-docusaurus.kinsta.page%2Fdataprime%2Flanguage-reference%2Ffunctions-reference%2Fstring%2Flength.md%20and%20help%20me%20with%20my%20question%20about%20this%20Coralogix%20documentation%20page.)[Open in Claude](https://claude.ai/new?q=Read%20https%3A%2F%2Fdocs-docusaurus.kinsta.page%2Fdataprime%2Flanguage-reference%2Ffunctions-reference%2Fstring%2Flength.md%20and%20help%20me%20with%20my%20question%20about%20this%20Coralogix%20documentation%20page.)

# `length`

## Description

Returns the number of characters in a string.

## Syntax

Like many functions in DataPrime, `length` supports<!-- --> [two notations](https://docs-docusaurus.kinsta.page/dataprime/language-reference/functions-reference/.md),<!-- --> **function** and **method**. These interchangeable forms allow flexibility in how you structure expressions.

* Function notation
* Method notation

```
length(value: string): number
```

```
(value: string).length(): number
```

## Arguments

| Name    | Type     | Required | Description           |
| ------- | -------- | -------- | --------------------- |
| `value` | `string` | **true** | The string to measure |

## Example

**Count the number of characters in a string**

Consider the following document:

```
{

    "str_val": "such logs, much tracing, wow!"

}
```

Use `length` to count the number of characters:

### Example query

* Function notation
* Method notation

```
create str_val_len from length(str_val)
```

```
create str_val_len from str_val.length()
```

### Example output

```
{

    "str_val": "such logs, much tracing, wow!",

    "str_val_len": 29

}
```
