# HDEL

> Remove one or more fields from a hash.

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

```
HDEL key field [field ...]
```

- Group: Hash
- Complexity: O(N) where N is the number of fields to remove
- HotKV Cloud: all plans
- On-Premise: no license needed

`HDEL` removes the given fields, and any time to live they had, from the hash
stored at `key`. Fields that do not exist are ignored. When the last field is
removed, the key itself is deleted.

## Return value

| Case | RESP2 | RESP3 |
| --- | --- | --- |
| Success | Integer: the number of fields that were removed | Same |
| Key does not exist | Integer `0` | Same |

`HDEL` 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" lang "en"
(integer) 2
127.0.0.1:6379> HDEL user:1 lang missing
(integer) 1
127.0.0.1:6379> HDEL user:1 name
(integer) 1
127.0.0.1:6379> EXISTS user:1
(integer) 0
```

## Compatibility

Same as Redis 7.4 and Valkey 8.

## See also

[HSET](https://docs.hotkv.com/commands/hset/index.md), [HGETDEL](https://docs.hotkv.com/commands/hgetdel/index.md), [HEXISTS](https://docs.hotkv.com/commands/hexists/index.md),
[DEL](https://docs.hotkv.com/commands/del/index.md)