---
title: strings.strlen() function
description: strings.strlen() returns the length of a string. String length is determined by the number of UTF code points a string contains.
url: https://docs.influxdata.com/flux/v0/stdlib/strings/strlen/
estimated_tokens: 1414
product: Flux
version: v0
publisher: InfluxData
canonical: https://docs.influxdata.com/flux/v0/stdlib/strings/strlen/
date: '2024-04-08T16:01:02-06:00'
lastmod: '2024-04-08T16:01:02-06:00'
---

* Flux 0.18.0+

InfluxDB support

`strings.strlen()` returns the length of a string. String length is determined by the number of UTF code points a string contains.

##### Function type signature

```js
(v: string) => int
```

For more information, see [Function type signatures](/flux/v0/function-type-signatures/).

## Parameters

### v

(Required)
String value to measure.

## Examples

* [Filter based on string value length](#filter-based-on-string-value-length)
* [Store the length of string values](#store-the-length-of-string-values)

### Filter based on string value length

```js
import "strings"

data
    |> filter(fn: (r) => strings.strlen(v: r._value) <= 6)
```

[](#view-example-input-and-output)

View example input and output

#### Input data

|       \_time       | \_value |\*tag|
|--------------------|---------|-----|
|2021-01-01T00:00:00Z|pl\_gqcz | t1  |
|2021-01-01T00:00:10Z| pl\_gvn | t1  |
|2021-01-01T00:00:20Z| pl\_phw | t1  |
|2021-01-01T00:00:30Z|pl\_guvzy| t1  |
|2021-01-01T00:00:40Z|pl\_vcce | t1  |
|2021-01-01T00:00:50Z| pl\_fgy | t1  |

|       \_time       | \_value |\*tag|
|--------------------|---------|-----|
|2021-01-01T00:00:00Z|pl\_beida| t2  |
|2021-01-01T00:00:10Z|pl\_euoxp| t2  |
|2021-01-01T00:00:20Z| pl\_gtz | t2  |
|2021-01-01T00:00:30Z|pl\_oxut | t2  |
|2021-01-01T00:00:40Z| pl\_wf  | t2  |
|2021-01-01T00:00:50Z|pl\_dtnbv| t2  |

#### Output data

|       \_time       |\_value|\*tag|
|--------------------|-------|-----|
|2021-01-01T00:00:10Z|pl\_gvn| t1  |
|2021-01-01T00:00:20Z|pl\_phw| t1  |
|2021-01-01T00:00:50Z|pl\_fgy| t1  |

|       \_time       |\_value|\*tag|
|--------------------|-------|-----|
|2021-01-01T00:00:20Z|pl\_gtz| t2  |
|2021-01-01T00:00:40Z|pl\_wf | t2  |

### Store the length of string values

```js
import "strings"

data
    |> map(fn: (r) => ({r with length: strings.strlen(v: r._value)}))
```

[](#view-example-input-and-output)

View example input and output

#### Input data

|       \_time       | \_value |\*tag|
|--------------------|---------|-----|
|2021-01-01T00:00:00Z|pl\_gqcz | t1  |
|2021-01-01T00:00:10Z| pl\_gvn | t1  |
|2021-01-01T00:00:20Z| pl\_phw | t1  |
|2021-01-01T00:00:30Z|pl\_guvzy| t1  |
|2021-01-01T00:00:40Z|pl\_vcce | t1  |
|2021-01-01T00:00:50Z| pl\_fgy | t1  |

|       \_time       | \_value |\*tag|
|--------------------|---------|-----|
|2021-01-01T00:00:00Z|pl\_beida| t2  |
|2021-01-01T00:00:10Z|pl\_euoxp| t2  |
|2021-01-01T00:00:20Z| pl\_gtz | t2  |
|2021-01-01T00:00:30Z|pl\_oxut | t2  |
|2021-01-01T00:00:40Z| pl\_wf  | t2  |
|2021-01-01T00:00:50Z|pl\_dtnbv| t2  |

#### Output data

|       \_time       | \_value |length|\*tag|
|--------------------|---------|------|-----|
|2021-01-01T00:00:00Z|pl\_gqcz |  7   | t1  |
|2021-01-01T00:00:10Z| pl\_gvn |  6   | t1  |
|2021-01-01T00:00:20Z| pl\_phw |  6   | t1  |
|2021-01-01T00:00:30Z|pl\_guvzy|  8   | t1  |
|2021-01-01T00:00:40Z|pl\_vcce |  7   | t1  |
|2021-01-01T00:00:50Z| pl\_fgy |  6   | t1  |

|       \_time       | \_value |length|\*tag|
|--------------------|---------|------|-----|
|2021-01-01T00:00:00Z|pl\_beida|  8   | t2  |
|2021-01-01T00:00:10Z|pl\_euoxp|  8   | t2  |
|2021-01-01T00:00:20Z| pl\_gtz |  6   | t2  |
|2021-01-01T00:00:30Z|pl\_oxut |  7   | t2  |
|2021-01-01T00:00:40Z| pl\_wf  |  5   | t2  |
|2021-01-01T00:00:50Z|pl\_dtnbv|  8   | t2  |
| _time | _value | *tag |
| --- | --- | --- |
| _time | _value | *tag |
| 2021-01-01T00:00:00Z | pl_gqcz | t1 |
| 2021-01-01T00:00:10Z | pl_gvn | t1 |
| 2021-01-01T00:00:20Z | pl_phw | t1 |
| 2021-01-01T00:00:30Z | pl_guvzy | t1 |
| 2021-01-01T00:00:40Z | pl_vcce | t1 |
| 2021-01-01T00:00:50Z | pl_fgy | t1 |

| _time | _value | *tag |
| --- | --- | --- |
| _time | _value | *tag |
| 2021-01-01T00:00:00Z | pl_beida | t2 |
| 2021-01-01T00:00:10Z | pl_euoxp | t2 |
| 2021-01-01T00:00:20Z | pl_gtz | t2 |
| 2021-01-01T00:00:30Z | pl_oxut | t2 |
| 2021-01-01T00:00:40Z | pl_wf | t2 |
| 2021-01-01T00:00:50Z | pl_dtnbv | t2 |

| _time | _value | *tag |
| --- | --- | --- |
| _time | _value | *tag |
| 2021-01-01T00:00:10Z | pl_gvn | t1 |
| 2021-01-01T00:00:20Z | pl_phw | t1 |
| 2021-01-01T00:00:50Z | pl_fgy | t1 |

| _time | _value | *tag |
| --- | --- | --- |
| _time | _value | *tag |
| 2021-01-01T00:00:20Z | pl_gtz | t2 |
| 2021-01-01T00:00:40Z | pl_wf | t2 |

| _time | _value | *tag |
| --- | --- | --- |
| _time | _value | *tag |
| 2021-01-01T00:00:00Z | pl_gqcz | t1 |
| 2021-01-01T00:00:10Z | pl_gvn | t1 |
| 2021-01-01T00:00:20Z | pl_phw | t1 |
| 2021-01-01T00:00:30Z | pl_guvzy | t1 |
| 2021-01-01T00:00:40Z | pl_vcce | t1 |
| 2021-01-01T00:00:50Z | pl_fgy | t1 |

| _time | _value | *tag |
| --- | --- | --- |
| _time | _value | *tag |
| 2021-01-01T00:00:00Z | pl_beida | t2 |
| 2021-01-01T00:00:10Z | pl_euoxp | t2 |
| 2021-01-01T00:00:20Z | pl_gtz | t2 |
| 2021-01-01T00:00:30Z | pl_oxut | t2 |
| 2021-01-01T00:00:40Z | pl_wf | t2 |
| 2021-01-01T00:00:50Z | pl_dtnbv | t2 |

| _time | _value | length | *tag |
| --- | --- | --- | --- |
| _time | _value | length | *tag |
| 2021-01-01T00:00:00Z | pl_gqcz | 7 | t1 |
| 2021-01-01T00:00:10Z | pl_gvn | 6 | t1 |
| 2021-01-01T00:00:20Z | pl_phw | 6 | t1 |
| 2021-01-01T00:00:30Z | pl_guvzy | 8 | t1 |
| 2021-01-01T00:00:40Z | pl_vcce | 7 | t1 |
| 2021-01-01T00:00:50Z | pl_fgy | 6 | t1 |

| _time | _value | length | *tag |
| --- | --- | --- | --- |
| _time | _value | length | *tag |
| 2021-01-01T00:00:00Z | pl_beida | 8 | t2 |
| 2021-01-01T00:00:10Z | pl_euoxp | 8 | t2 |
| 2021-01-01T00:00:20Z | pl_gtz | 6 | t2 |
| 2021-01-01T00:00:30Z | pl_oxut | 7 | t2 |
| 2021-01-01T00:00:40Z | pl_wf | 5 | t2 |
| 2021-01-01T00:00:50Z | pl_dtnbv | 8 | t2 |
