<a id="keytovalue"></a>

# Kafka Connect KeyToValue SMT Usage Reference for Confluent Cloud

The following provides usage information for the SMT `com.clickhouse.kafka.connect.transforms.KeyToValue`.

## Description

The `KeyToValue` SMT converts Kafka message key into a value. It is particularly useful when you want to store a
message’s key data directly within its value. By default, the key’s content is added to the value under a new
field named `_key` with a `String` type.

To apply the `KeyToValue` SMT, add the following to your connector configuration:

```bash
"transforms": "KeyToValue",
"transforms.KeyToValue.type": "com.clickhouse.kafka.connect.transforms.KeyToValue",
"transforms.KeyToValue.fields": "<key-name>"
```

Replace the `<field-name>` with the message key you want to convert into a value.

## Examples

The example below shows how to use `KeyToValue` SMT.

Consider a Kafka message with the following key and value:

- **Key**:
  ```json
  123
  ```
- **Value (before SMT):**
  ```json
  {
    "name": "John Doe",
    "email": "john.doe@example.com"
  }
  ```
- **Adding the SMT to your Connector Configuration:**

  To apply the `KeyToValue` SMT, add the following to your connector configuration:
  ```bash
  "transforms": "KeyToValue",
  "transforms.KeyToValue.type": "com.clickhouse.kafka.connect.transforms.KeyToValue",
  "transforms.KeyToValue.fields": "customer_id"
  ```
- **Value (after SMT):**

  After the `KeyToValue` SMT applies, the message value transforms as follows:
  ```json
  {
    "customer_id": 123,
    "name": "John Doe",
    "email": "john.doe@example.com"
  }
  ```
