# BITCONVERT

```json metadata
{
  "schema_version": 2,
  "title": "BITCONVERT",
  "description": "Converts a string bitmap to the native bitmap representation.",
  "categories": ["docs","develop","stack","oss","rs","rc","oss","kubernetes","clients"],
  "arguments": [{"display_text":"key","key_spec_index":0,"name":"key","type":"key"}],
  "syntax_fmt": "BITCONVERT key",
  "complexity": "O(N) where N is the length of the string value.",
  "group": "bitmap",
  "command_flags": ["write","denyoom","noscript","internal"],
  "acl_categories": ["@write","@bitmap","@slow"],
  "since": "8.12.0",
  "arity": 2,
  "key_specs": [{"RW":true,"access":true,"begin_search":{"spec":{"index":1},"type":"index"},"find_keys":{"spec":{"keystep":1,"lastkey":0,"limit":0},"type":"range"},"update":true}],
  "tableOfContents": {"sections":[{"id":"required-arguments","title":"Required arguments"},{"id":"details","title":"Details"},{"id":"redis-software-and-redis-cloud-compatibility","title":"Redis Software and Redis Cloud compatibility"},{"id":"return-information","title":"Return information"},{"id":"see-also","title":"See also"},{"id":"related-topics","title":"Related topics"}]}

,
  "codeExamples": []
}
```


`BITCONVERT` is an internal command that preserves string-to-native bitmap
conversions during replication and append-only file (AOF) replay. Applications
cannot call it directly.

## Required arguments

<details open><summary><code>key</code></summary>

The key to convert to a native bitmap.

</details>

## Details

Redis uses this command to replay a representation change independently of the
receiving node's `bitmap-default-roaring` setting. Ordinary clients receive an
unknown-command error and do not see it in `COMMAND INFO` or `COMMAND DOCS`.

Converting a string preserves its bits, logical byte length, and expiration.
A missing key becomes an empty native bitmap. An existing native bitmap is
unchanged. Other value types return `WRONGTYPE`; strings beyond the supported
native bitmap length return an error.

## Redis Software and Redis Cloud compatibility

| Redis<br />Software | Redis<br />Cloud | <span style="min-width: 9em; display: table-cell">Notes</span> |
|:----------------------|:-----------------|:------|
| <span title="Not supported">&#x274c; Standard</span><br /><span title="Not supported"><nobr>&#x274c; Active-Active</nobr></span> | <span title="Not supported">&#x274c; Standard</span><br /><span title="Not supported"><nobr>&#x274c; Active-Active</nobr></span> |  |

## Return information

**RESP2:**

[Simple string reply](../../develop/reference/protocol-spec#simple-strings): `OK`.

**RESP3:**

[Simple string reply](../../develop/reference/protocol-spec#simple-strings): `OK`.



## See also

[`SETBIT`](https://redis.io/docs/latest/commands/setbit) | [`BITROAROP`](https://redis.io/docs/latest/commands/bitroarop)

## Related topics

- [Roaring-compressed bitmaps](https://redis.io/docs/latest/develop/data-types/strings/bitmaps#roaring-compressed-bitmaps)

