{
  "id": "resp_js_conversion",
  "title": "RESP & JavaScript",
  "url": "https://redis.io/docs/latest/operate/oss_and_stack/stack-with-enterprise/deprecated-features/triggers-and-functions/concepts/resp_js_conversion/",
  "summary": "Converting RESP to and from JavaScript",
  "tags": [
    "docs",
    "develop",
    "stack",
    "oss",
    "rs",
    "rc",
    "oss",
    "kubernetes",
    "clients"
  ],
  "last_updated": "2026-04-01T08:10:08-05:00",
  "page_type": "content",
  "content_hash": "4e4f7f57b78ec686574970c82b08ed29af1f8972bca6cfb0377a1a1e7650252d",
  "sections": [
    {
      "id": "overview",
      "title": "Overview",
      "role": "overview",
      "text": "When running Redis commands from within a function using the `client.call` API, the reply is parsed as a resp3 reply and converted to a JS object using the following rules:\n\n| resp 3            | JS object type                                                                                                                                 |\n|-------------------|------------------------------------------------------------------------------------------------------------------------------------------------|\n| `status`          | `StringObject` with a field called `__reply_type` and value `status` (or error if failed to convert to utf8)                                   |\n| `bulk string`     | JS `String` (or error if failed to convert to utf8)                                                                                            |\n| `Error`           | Raise JS exception                                                                                                                             |\n| `long`            | JS big integer                                                                                                                                 |\n| `double`          | JS number                                                                                                                                      |\n| `array`           | JS array                                                                                                                                       |\n| `map`             | JS object                                                                                                                                      |\n| `set`             | JS set                                                                                                                                         |\n| `bool`            | JS boolean                                                                                                                                     |\n| `big number`      | `StringObject` with a field called `__reply_type` and value `big_number`                                                                       |\n| `verbatim string` | `StringObject` with 2 additional fields: 1. `__reply_type` and value `verbatim` 2. `__format` with the value of the ext in the verbatim string (or error if failed to convert to utf8) |\n| `null`            | JS null                                                                                                                                        |\n|                   |                                                                                                                                                |\n\nWhen running Redis commands from within a function using the `client.callRaw` API, the reply is parsed as a resp3 reply and converted to a JS object using the following rules:\n\n| resp 3            | JS object type                                                                                                                                 |\n|-------------------|------------------------------------------------------------------------------------------------------------------------------------------------|\n| `status`          | JS `ArrayBuffer` with a field called `__reply_type` and value `status`                                                                        |\n| `bulk string`     | JS `ArrayBuffer`                                                                                                                              |\n| `Error`           | Raise JS exception                                                                                                                             |\n| `long`            | JS big integer                                                                                                                                 |\n| `double`          | JS number                                                                                                                                      |\n| `array`           | JS array                                                                                                                                       |\n| `map`             | JS object                                                                                                                                      |\n| `set`             | JS set                                                                                                                                         |\n| `bool`            | JS boolean                                                                                                                                     |\n| `big number`      | `StringObject` with a field called `__reply_type` and value `big_number`                                                                       |\n| `verbatim string` | JS `ArrayBuffer` with 2 additional fields: 1. `__reply_type` and value `verbatim` 2. `__format` with the value of the ext in the verbatim string |\n| `null`            | JS null                                                                                                                                        |\n|                   |                                                                                                                                                |"
    },
    {
      "id": "javascript-to-resp-conversion",
      "title": "JavaScript to RESP conversion",
      "role": "content",
      "text": "| JS type                                                          | RESP2         | RESP3                                  |\n|------------------------------------------------------------------|---------------|----------------------------------------|\n| `string`                                                         | `bulk string` | `bulk string`                          |\n| `string` object with field `__reply_type=status`                 | `status`      | `status`                               |\n| Exception                                                        | `error`       | `error`                                |\n| `big integer`                                                    | `long`        | `long`                                 |\n| `number`                                                         | `bulk string` | `double`                               |\n| `array`                                                          | `array`       | `array`                                |\n| `map`                                                            | `array`       | `map`                                  |\n| `set`                                                            | `array`       | `set`                                  |\n| `bool`                                                           | `long`        | `bool`                                 |\n| `string` object with field`__reply_type=varbatim` and `__format=txt` | `bulk string` | `verbatim string` with format as `txt` |\n| `null`                                                           | resp2 `null`  | resp3 `null`                           |"
    }
  ],
  "examples": []
}
