--- acl_categories: - '@read' - '@string' - '@fast' arguments: - display_text: key key_spec_index: 0 name: key type: key arity: 2 categories: - docs - develop - stack - oss - rs - rc - oss - kubernetes - clients command_flags: - readonly - fast complexity: O(1) description: Returns the length of a string value. group: string hidden: false key_specs: - RO: true begin_search: spec: index: 1 type: index find_keys: spec: keystep: 1 lastkey: 0 limit: 0 type: range linkTitle: STRLEN railroad_diagram: /images/railroad/strlen.svg since: 2.2.0 summary: Returns the length of a string value. syntax_fmt: STRLEN key title: STRLEN --- Returns the length of the string value stored at `key`. An error is returned when `key` holds a non-string value. ## Examples {{% redis-cli %}} SET mykey "Hello world" STRLEN mykey STRLEN nonexisting {{% /redis-cli %}} ## Redis Software and Redis Cloud compatibility | Redis
Software | Redis
Cloud | Notes | |:----------------------|:-----------------|:------| | ✅ Standard
✅ Active-Active | ✅ Standard
✅ Active-Active | | ## Return information {{< multitabs id="strlen-return-info" tab1="RESP2" tab2="RESP3" >}} [Integer reply](../../develop/reference/protocol-spec#integers): the length of the string stored at key, or 0 when the key does not exist. -tab-sep- [Integer reply](../../develop/reference/protocol-spec#integers): the length of the string stored at key, or 0 when the key does not exist. {{< /multitabs >}}