content/commands/hdel.md
Removes the specified fields from the hash stored at key.
Specified fields that do not exist within this hash are ignored.
Deletes the hash if no fields remain.
If key does not exist, it is treated as an empty hash and this command returns
0.
{{< clients-example set="cmds_hash" step="hdel" description="Foundational: Delete one or more fields from a hash using HDEL (returns count of deleted fields, ignores non-existent fields)" difficulty="beginner" >}} HSET myhash field1 "foo" (integer) 1 HDEL myhash field1 (integer) 1 HDEL myhash field2 (integer) 0 {{< /clients-example >}}
Give these commands a try in the interactive console:
{{% redis-cli %}} HSET myhash field1 "foo" HDEL myhash field1 HDEL myhash field2 {{% /redis-cli %}}
| Redis Software | Redis Cloud | <span style="min-width: 9em; display: table-cell">Notes</span> | |:----------------------|:-----------------|:------| | <span title="Supported">✅ Standard</span> <span title="Supported"><nobr>✅ Active-Active</nobr></span> | <span title="Supported">✅ Standard</span> <span title="Supported"><nobr>✅ Active-Active</nobr></span> | |
{{< multitabs id="hdel-return-info" tab1="RESP2" tab2="RESP3" >}}
Integer reply: the number of fields that were removed from the hash, excluding any specified but non-existing fields.
-tab-sep-
Integer reply: The number of fields that were removed from the hash, excluding any specified but non-existing fields.
{{< /multitabs >}}