{
  "schema_version": 2,
  "id": "commands/hvals",
  "title": "HVALS",
  "url": "https://redis.io/docs/latest/commands/hvals/",
  "summary": "Returns all values in a hash.",
  "since": "2.0.0",
  "tags": [
    "docs",
    "develop",
    "stack",
    "oss",
    "rs",
    "rc",
    "oss",
    "kubernetes",
    "clients"
  ],
  "last_updated": "2026-07-08T12:05:04+02:00",
  "page_type": "content",
  "content_hash": "d485d3e8b7e924b3c6e3e007cba4d9297bd6b87aa8902c85029cd9275db0863d",
  "sections": [
    {
      "id": "required-arguments",
      "title": "Required arguments",
      "role": "content",
      "text": "<details open><summary><code>key</code></summary>\n\nThe name of the key that holds the hash.\n\n</details>"
    },
    {
      "id": "examples",
      "title": "Examples",
      "role": "example",
      "text": "Foundational: Retrieve all values from a hash using HVALS (returns only values without field names, useful when you only need the data)\n\n**Difficulty:** Beginner\n\n**Commands:** HSET, HVALS\n\n**Complexity:**\n- HSET: O(1)\n- HVALS: O(N)\n\n**Available in:** Redis CLI, C, C#, Go, Java, Java (Asynchronous - Lettuce), Java (Reactive - Lettuce), Java (Synchronous - Jedis), JavaScript (Node.js), JavaScript (Node.js), PHP, Python, Ruby, Rust (Asynchronous), Rust (Synchronous)\n\n##### Redis CLI\n\n[code example]\n\n##### C\n\n[code example]\n\n##### C#\n\n[code example]\n\n##### Go\n\n[code example]\n\n##### Java\n\n[code example]\n\n##### Java (Asynchronous - Lettuce)\n\n[code example]\n\n##### Java (Reactive - Lettuce)\n\n[code example]\n\n##### Java (Synchronous - Jedis)\n\n[code example]\n\n##### JavaScript (Node.js)\n\n[code example]\n\n##### JavaScript (Node.js)\n\n[code example]\n\n##### JavaScript (Node.js)\n\n[code example]\n\n##### JavaScript (Node.js)\n\n[code example]\n\n##### PHP\n\n[code example]\n\n##### Python\n\n[code example]\n\n##### Ruby\n\n[code example]\n\n##### Rust (Asynchronous)\n\n[code example]\n\n##### Rust (Synchronous)\n\n[code example]"
    },
    {
      "id": "redis-software-and-redis-cloud-compatibility",
      "title": "Redis Software and Redis Cloud compatibility",
      "role": "content",
      "text": "| Redis<br />Software | Redis<br />Cloud | <span style=\"min-width: 9em; display: table-cell\">Notes</span> |\n|:----------------------|:-----------------|:------|\n| <span title=\"Supported\">&#x2705; Standard</span><br /><span title=\"Supported\"><nobr>&#x2705; Active-Active</nobr></span> | <span title=\"Supported\">&#x2705; Standard</span><br /><span title=\"Supported\"><nobr>&#x2705; Active-Active</nobr></span> |  |"
    },
    {
      "id": "return-information",
      "title": "Return information",
      "role": "returns",
      "text": "**RESP2:**\n\n[Array reply](../../develop/reference/protocol-spec#arrays): a list of values in the hash, or an empty list when the key does not exist\n\n**RESP3:**\n\n[Array reply](../../develop/reference/protocol-spec#arrays): a list of values in the hash, or an empty list when the key does not exist."
    }
  ],
  "examples": [
    {
      "id": "examples-ex0",
      "language": "plaintext",
      "code": "redis> HSET myhash field1 \"Hello\"\n(integer) 1\nredis> HSET myhash field2 \"World\"\n(integer) 1\nredis> HVALS myhash\n1) \"Hello\"\n2) \"World\"",
      "section_id": "examples"
    },
    {
      "id": "examples-ex1",
      "language": "c",
      "code": "reply = redisCommand(c, \"HSET myhash field1 Hello field2 World\");\n    freeReplyObject(reply);\n\n    reply = redisCommand(c, \"HVALS myhash\");\n    for (size_t i = 0; i < reply->elements; i++) {\n        printf(\"%s\\n\", reply->element[i]->str);\n    }\n    // >>> Hello\n    // >>> World\n    freeReplyObject(reply);",
      "section_id": "examples"
    },
    {
      "id": "examples-ex2",
      "language": "csharp",
      "code": "db.HashSet(\"myhash\",\n            [\n                new(\"field1\", \"Hello\"),\n                new(\"field2\", \"World\")\n            ]\n        );\n\n        RedisValue[] hValsResult = db.HashValues(\"myhash\");\n        Array.Sort(hValsResult);\n        Console.WriteLine(string.Join(\", \", hValsResult));\n        // >>> Hello, World",
      "section_id": "examples"
    },
    {
      "id": "examples-ex3",
      "language": "go",
      "code": "hValsResult1, err := rdb.HSet(ctx, \"myhash\",\n\t\t\"field1\", \"Hello\",\n\t\t\"field2\", \"World\",\n\t).Result()\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(hValsResult1) // >>> 2\n\n\thValsResult2, err := rdb.HVals(ctx, \"myhash\").Result()\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tsort.Strings(hValsResult2)\n\n\tfmt.Println(hValsResult2) // >>> [Hello World]",
      "section_id": "examples"
    },
    {
      "id": "examples-ex4",
      "language": "java",
      "code": "Map<String, String> hValsFields = new HashMap<>();\n            hValsFields.put(\"field1\", \"Hello\");\n            hValsFields.put(\"field2\", \"World\");\n\n            syncCommands.hset(\"myhash\", hValsFields);\n\n            // The order of the values isn't guaranteed, so sort them before\n            // printing.\n            List<String> res15 = syncCommands.hvals(\"myhash\");\n            List<String> sortedValues = new ArrayList<>(res15);\n            Collections.sort(sortedValues);\n            System.out.println(sortedValues); // >>> [Hello, World]",
      "section_id": "examples"
    },
    {
      "id": "examples-ex5",
      "language": "java",
      "code": "Map<String, String> hValsExampleParams = new HashMap<>();\n            hValsExampleParams.put(\"field1\", \"Hello\");\n            hValsExampleParams.put(\"field2\", \"World\");\n\n            CompletableFuture<Void> hValsExample = asyncCommands.hset(\"myhash\", hValsExampleParams).thenCompose(res1 -> {\n                return asyncCommands.hvals(\"myhash\");\n            }).thenAccept(res2 -> {\n                List<String> sortedValues = new ArrayList<>(res2);\n                Collections.sort(sortedValues);\n                System.out.println(sortedValues);\n                // >>> [Hello, World]\n            }).toCompletableFuture();",
      "section_id": "examples"
    },
    {
      "id": "examples-ex6",
      "language": "java",
      "code": "Map<String, String> hValsExampleParams = new HashMap<>();\n            hValsExampleParams.put(\"field1\", \"Hello\");\n            hValsExampleParams.put(\"field2\", \"World\");\n\n            Mono<Long> hValsExample1 = reactiveCommands.hset(\"myhash\", hValsExampleParams).doOnNext(result -> {\n            });\n\n            hValsExample1.block();\n\n            Mono<List<String>> hValsExample2 = reactiveCommands.hvals(\"myhash\").collectList().doOnNext(result -> {\n                List<String> sortedValues = new ArrayList<>(result);\n                Collections.sort(sortedValues);\n                System.out.println(sortedValues);\n                // >>> [Hello, World]\n            });",
      "section_id": "examples"
    },
    {
      "id": "examples-ex7",
      "language": "java",
      "code": "Map<String, String> hValsExampleParams = new HashMap<>();\n        hValsExampleParams.put(\"field1\", \"Hello\");\n        hValsExampleParams.put(\"field2\", \"World\");\n\n        long hValsResult1 = jedis.hset(\"myhash\", hValsExampleParams);\n        System.out.println(hValsResult1); // >>> 2\n\n        List<String> hValsResult2 = jedis.hvals(\"myhash\");\n        Collections.sort(hValsResult2);\n        System.out.println(hValsResult2);\n        // >>> [Hello, World]",
      "section_id": "examples"
    },
    {
      "id": "examples-ex8",
      "language": "javascript",
      "code": "const res12 = await client.hSet(\n  'myhash',\n  {\n    'field1': 'Hello',\n    'field2': 'World'\n  }\n)\n\n// HVALS follows the hash's field order, which Redis does not promise, so sort.\nconst res13 = (await client.hVals('myhash')).sort()\nconsole.log(res13) // [ 'Hello', 'World' ]",
      "section_id": "examples"
    },
    {
      "id": "examples-ex9",
      "language": "javascript",
      "code": "await redis.hset('myhash', { field1: 'Hello', field2: 'World' });\n\n// HVALS follows the hash's field order, which Redis does not promise, so sort.\nconst hvalsRes = await redis.hvals('myhash');\nconsole.log(hvalsRes.sort()); // >>> [ 'Hello', 'World' ]",
      "section_id": "examples"
    },
    {
      "id": "examples-ex10",
      "language": "javascript",
      "code": "const res12 = await client.hSet(\n  'myhash',\n  {\n    'field1': 'Hello',\n    'field2': 'World'\n  }\n)\n\n// HVALS follows the hash's field order, which Redis does not promise, so sort.\nconst res13 = (await client.hVals('myhash')).sort()\nconsole.log(res13) // [ 'Hello', 'World' ]",
      "section_id": "examples"
    },
    {
      "id": "examples-ex11",
      "language": "javascript",
      "code": "await redis.hset('myhash', { field1: 'Hello', field2: 'World' });\n\n// HVALS follows the hash's field order, which Redis does not promise, so sort.\nconst hvalsRes = await redis.hvals('myhash');\nconsole.log(hvalsRes.sort()); // >>> [ 'Hello', 'World' ]",
      "section_id": "examples"
    },
    {
      "id": "examples-ex12",
      "language": "php",
      "code": "$hValsResult1 = $this->redis->hmset('myhash', ['field1' => 'Hello', 'field2' => 'World']);\n        echo \"HMSET myhash field1 Hello field2 World: \" . ($hValsResult1 ? 'OK' : 'FAIL') . \"\\n\"; // >>> OK\n\n        // HVALS follows the hash's field order, which Redis does not promise, so sort.\n        $hValsResult2 = $this->redis->hvals('myhash');\n        sort($hValsResult2);\n        echo \"HVALS myhash: \" . json_encode($hValsResult2) . \"\\n\"; // >>> [\"Hello\",\"World\"]",
      "section_id": "examples"
    },
    {
      "id": "examples-ex13",
      "language": "python",
      "code": "res10 = r.hset(\"myhash\", mapping={\"field1\": \"Hello\", \"field2\": \"World\"})\n\n# HVALS follows the hash's field order, which Redis does not promise, so sort.\nres11 = r.hvals(\"myhash\")\nprint(sorted(res11)) # >>> [ \"Hello\", \"World\" ]",
      "section_id": "examples"
    },
    {
      "id": "examples-ex14",
      "language": "ruby",
      "code": "r.hset('myhash', { 'field1' => 'Hello', 'field2' => 'World' })\n\n# HVALS follows the hash's field order, which Redis does not promise, so sort.\nres15 = r.hvals('myhash').sort\nputs res15.inspect # >>> [\"Hello\", \"World\"]",
      "section_id": "examples"
    },
    {
      "id": "examples-ex15",
      "language": "rust",
      "code": "let hash_fields = [\n            (\"field1\", \"Hello\"),\n            (\"field2\", \"World\"),\n        ];\n\n        if let Ok(_) = r.hset_multiple::<&str, &str, &str, String>(\"myhash\", &hash_fields).await {\n            // Fields set successfully\n        }\n\n        match r.hvals(\"myhash\").await {\n            Ok(res11) => {\n                let res11: Vec<String> = res11;\n                println!(\"{res11:?}\");    // >>> [\"Hello\", \"World\"]\n            },\n            Err(e) => {\n                println!(\"Error getting hash values: {e}\");\n                return;\n            }\n        }",
      "section_id": "examples"
    },
    {
      "id": "examples-ex16",
      "language": "rust",
      "code": "let hash_fields = [\n            (\"field1\", \"Hello\"),\n            (\"field2\", \"World\"),\n        ];\n\n        if let Ok(_) = r.hset_multiple::<&str, &str, &str, String>(\"myhash\", &hash_fields) {\n            // Fields set successfully\n        }\n\n        match r.hvals(\"myhash\") {\n            Ok(res11) => {\n                let res11: Vec<String> = res11;\n                println!(\"{res11:?}\");    // >>> [\"Hello\", \"World\"]\n            },\n            Err(e) => {\n                println!(\"Error getting hash values: {e}\");\n                return;\n            }\n        }",
      "section_id": "examples"
    }
  ]
}
