# `length`

## Description

Returns the number of characters in a string.

## Syntax

Like many functions in DataPrime, `length` supports [two notations](https://coralogix.com/docs/dataprime/language-reference/functions-reference/index.md), **function** and **method** notation. These interchangeable forms allow flexibility in how you structure expressions.

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

```dataprime
(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:

```json
{
    "str_val": "such logs, much tracing, wow!"
}
```

Use `length` to count the number of characters:

### Example query

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

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

### Example output

```json
{
    "str_val": "such logs, much tracing, wow!",
    "str_val_len": 29
}
```
