# HSTRLEN

> Get the length in bytes of a hash field's value.

URL: https://docs.hotkv.com/commands/hstrlen/

```
HSTRLEN key field
```

- Group: Hash
- Complexity: O(1)
- HotKV Cloud: all plans
- On-Premise: no license needed

`HSTRLEN` returns the length, in bytes, of the value stored in `field` of the
hash at `key`.

## Return value

| Case | RESP2 | RESP3 |
| --- | --- | --- |
| Field exists | Integer: the value's length in bytes | Same |
| Field or key does not exist | Integer `0` | Same |

`HSTRLEN` replies with a `WRONGTYPE` error if `key` holds a value that is not
a hash.

## Examples

```
127.0.0.1:6379> HSET user:1 name "Ada" bio "Mathematician"
(integer) 2
127.0.0.1:6379> HSTRLEN user:1 bio
(integer) 13
127.0.0.1:6379> HSTRLEN user:1 email
(integer) 0
```

## Compatibility

Same as Redis 7.4 and Valkey 8.

## See also

[HGET](https://docs.hotkv.com/commands/hget/index.md), [HLEN](https://docs.hotkv.com/commands/hlen/index.md), [STRLEN](https://docs.hotkv.com/commands/strlen/index.md)