Strings Strlen
# Redis STRLEN Command
[!(#) Redis Strings](#)
The Redis STRLEN command is used to get the length of the string value stored at a specified key. It returns an error if the value stored at the key is not a string.
### Syntax
The basic syntax for the Redis STRLEN command is as follows:
redis 127.0.0.1:6379> STRLEN KEY_NAME
### Available Since
>= 2.2.0
### Return Value
The length of the string value. Returns 0 when the key does not exist.
### Example
# Get the length of a string redis> SET mykey "Hello world" OK redis> STRLEN mykey (integer) 11# Length of a non-existing key is 0 redis> STRLEN nonexisting (integer) 0
[!(#) Redis Strings](#)
YouTip