---
title: "STRLEN"
url: "https://docs.yugabyte.com/stable/yedis/api/strlen/"
---

# STRLEN

## Synopsis

**`STRLEN key`**

This command finds the length of the string value that is associated with the given `key`.

- If `key` is associated with a non-string value, an error is raised.
- If `key` does not exist, 0 is returned.

## Return value

Returns length of the specified string.

## Examples

```sh
$ SET yugakey "string value"
```

```
"OK"
```

```sh
$ STRLEN yugakey
```

```
12
```

```sh
$ STRLEN undefined_key
```

```
0
```

## See also

[`append`](/stable/yedis/api/append/ "append"), [`get`](/stable/yedis/api/get/ "get"), [`getrange`](/stable/yedis/api/getrange/ "getrange"), [`getset`](/stable/yedis/api/getset/ "getset"), [`incr`](/stable/yedis/api/incr/ "incr"), [`incrby`](/stable/yedis/api/incrby/ "incrby"), [`set`](/stable/yedis/api/set/ "set"), [`setrange`](/stable/yedis/api/setrange/ "setrange")
