{
  "id": "himport",
  "title": "HIMPORT",
  "url": "https://redis.io/docs/latest/commands/himport/",
  "summary": "A container for session-based hash import commands using fieldsets.",
  "tags": [
    "docs",
    "develop",
    "stack",
    "oss",
    "rs",
    "rc",
    "oss",
    "kubernetes",
    "clients"
  ],
  "last_updated": "2026-07-30T08:54:30-07:00",
  "page_type": "content",
  "content_hash": "d332af87e1da884b4a29a6ca21cd766e48165c96a48606640b5de03999e78fc6",
  "sections": [
    {
      "id": "overview",
      "title": "Overview",
      "role": "overview",
      "text": "`HIMPORT` is a container command for session-based bulk hash import. Its subcommands let a client import many hashes that share the same field names efficiently by declaring those field names once and then sending only the values for each key.\n\nThe subcommands are:\n\n- [`HIMPORT PREPARE`](https://redis.io/docs/latest/commands/himport-prepare) — define a session-local fieldset that names an ordered list of field names.\n- [`HIMPORT SET`](https://redis.io/docs/latest/commands/himport-set) — create a hash from a prepared fieldset and a list of values.\n- [`HIMPORT DISCARD`](https://redis.io/docs/latest/commands/himport-discard) — remove a single fieldset by name.\n- [`HIMPORT DISCARDALL`](https://redis.io/docs/latest/commands/himport-discardall) — remove every fieldset held by the connection."
    },
    {
      "id": "details",
      "title": "Details",
      "role": "content",
      "text": "A *fieldset* is a named, ordered list of field names that is scoped to the client connection: it is not visible to other clients and is discarded when the connection closes or the client issues the [`RESET`](https://redis.io/docs/latest/commands/reset) command. A connection can prepare several fieldsets, each under its own name, and refer to them by name in later commands.\n\nThe typical workflow is to declare a fieldset once with [`HIMPORT PREPARE`](https://redis.io/docs/latest/commands/himport-prepare), then create many keys from it with [`HIMPORT SET`](https://redis.io/docs/latest/commands/himport-set), sending only the values each time:\n\n[code example]\n\nBecause every key created this way shares one fixed set of field names, `HIMPORT` reduces the network traffic and per-command work compared with running [`HSET`](https://redis.io/docs/latest/commands/hset) once per key. Redis also uses the shared field names as a hint to store the keys as [compact hashes](https://redis.io/docs/latest/develop/data-types/hashes#compact-hashes), an internal encoding that keeps a single copy of the field names and reduces memory when many keys share the same layout. This encoding does not change the behavior or replies of any existing hash command."
    }
  ],
  "examples": [
    {
      "id": "details-ex0",
      "language": "plaintext",
      "code": "HIMPORT PREPARE u name email age\nHIMPORT SET user:1 u alice a@example.com 30\nHIMPORT SET user:2 u bob b@example.com 25",
      "section_id": "details"
    }
  ]
}
