# HEXISTS

> Check whether a field exists in a hash.

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

```
HEXISTS key field
```

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

`HEXISTS` tells you whether `field` is present in the hash stored at `key`. A
field whose time to live has passed counts as absent.

## Return value

| Case | RESP2 | RESP3 |
| --- | --- | --- |
| Field exists | Integer `1` | Same |
| Field or key does not exist | Integer `0` | Same |

`HEXISTS` 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"
(integer) 1
127.0.0.1:6379> HEXISTS user:1 name
(integer) 1
127.0.0.1:6379> HEXISTS 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), [HKEYS](https://docs.hotkv.com/commands/hkeys/index.md),
[EXISTS](https://docs.hotkv.com/commands/exists/index.md)