> ## Documentation Index
> Fetch the complete documentation index at: https://mintlify.com/upstash/redis-js/llms.txt
> Use this file to discover all available pages before exploring further.

# HVALS

> Get all values in a hash

## Usage

Returns all values in the hash stored at `key`.

```typescript theme={null}
await redis.hvals(key);
```

## Parameters

<ParamField path="key" type="string" required>
  The key of the hash
</ParamField>

## Response

<ResponseField name="values" type="TData[]">
  An array of values in the hash. Returns an empty array if the key does not exist.

  Values are automatically parsed from JSON when possible.
</ResponseField>

## Examples

### Get all values

```typescript theme={null}
import { Redis } from '@upstash/redis';

const redis = new Redis({
  url: process.env.UPSTASH_REDIS_REST_URL!,
  token: process.env.UPSTASH_REDIS_REST_TOKEN!,
});

// Set hash fields
await redis.hset('user:1000', {
  name: 'Alice',
  email: 'alice@example.com',
  age: 30,
  city: 'New York'
});

// Get all values
const values = await redis.hvals('user:1000');
console.log(values); // ['Alice', 'alice@example.com', 30, 'New York']
```

### Working with typed data

```typescript theme={null}
interface UserValue {
  name?: string;
  email?: string;
  age?: number;
  city?: string;
}

type UserValues = Array<string | number>;

const values = await redis.hvals<UserValues>('user:1000');
console.log(values);
```

### Process all values

```typescript theme={null}
// Get all product prices
const prices = await redis.hvals<number[]>('product:prices');

// Calculate average
const average = prices.reduce((sum, price) => sum + price, 0) / prices.length;
console.log(`Average price: $${average.toFixed(2)}`);

// Find min and max
const min = Math.min(...prices);
const max = Math.max(...prices);
console.log(`Price range: $${min} - $${max}`);
```

### Non-existent key

```typescript theme={null}
const values = await redis.hvals('user:9999');
console.log(values); // []
```

### Count occurrences

```typescript theme={null}
// Get all status values
const statuses = await redis.hvals<string[]>('order:statuses');

// Count each status
const statusCounts = statuses.reduce((acc, status) => {
  acc[status] = (acc[status] || 0) + 1;
  return acc;
}, {} as Record<string, number>);

console.log(statusCounts);
// { pending: 5, shipped: 3, delivered: 2 }
```

### Filter values

```typescript theme={null}
// Get all ages
const ages = await redis.hvals<number[]>('users:ages');

// Filter adults
const adults = ages.filter(age => age >= 18);
console.log(`Adults: ${adults.length}`);
```

### Check for duplicates

```typescript theme={null}
const emails = await redis.hvals<string[]>('users:emails');
const uniqueEmails = new Set(emails);

if (emails.length !== uniqueEmails.size) {
  console.log('Duplicate emails found!');
}
```

### Sum numeric values

```typescript theme={null}
// Get all point values
const points = await redis.hvals<number[]>('user:1000:scores');

// Calculate total
const total = points.reduce((sum, points) => sum + points, 0);
console.log(`Total points: ${total}`);
```

### Validate all values

```typescript theme={null}
const urls = await redis.hvals<string[]>('config:endpoints');

// Check if all URLs are valid
const allValid = urls.every(url => {
  try {
    new URL(url);
    return true;
  } catch {
    return false;
  }
});

console.log(`All URLs valid: ${allValid}`);
```

### Export values list

```typescript theme={null}
// Get all feature flags
const features = await redis.hvals<boolean[]>('app:features');

const enabledCount = features.filter(Boolean).length;
console.log(`${enabledCount} of ${features.length} features enabled`);
```

## Notes

* The order of values in the returned array is not guaranteed
* The order corresponds to the order of fields returned by `HKEYS`
* Returns an empty array for non-existent keys
* Use `HGETALL` if you need both field names and values
* For very large hashes, consider using `HSCAN` to iterate incrementally

## See Also

* [HKEYS](/api/commands/hkeys) - Get all field names in a hash
* [HGETALL](/api/commands/hgetall) - Get all fields and values in a hash
* [HGET](/api/commands/hget) - Get a specific hash field value
