---
title: length
description: |
  Returns the number of characters in a string.
url: https://coralogix.com/docs/dataprime/language-reference/functions-reference/string/length/
product: dataengine
feature: DataPrime Language
feature_id: dataprime-language
feature_identifier: dataengine/dataprime-language
last_updated: '2026-10-21'
---

# `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.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

}
```
