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

# Map keys

> Performs actions on keys in the data.

export const FormField = ({property, label, required = false, diType, uiPatterns, children}) => {
  const patterns = Array.isArray(uiPatterns) ? uiPatterns : uiPatterns ? [uiPatterns] : [];
  return <div style={{
    margin: '1.5rem 0'
  }}>
      <div style={{
    display: 'flex',
    alignItems: 'baseline',
    flexWrap: 'wrap',
    gap: '0.5rem',
    marginBottom: '0.25rem'
  }}>
        <strong>{label}</strong>
        <span style={{
    fontSize: '0.7rem',
    fontWeight: 600,
    textTransform: 'uppercase',
    letterSpacing: '0.04em',
    color: required ? '#6241f5' : '#6b7280'
  }}>
          {required ? 'Required' : 'Optional'}
        </span>
      </div>

      <div>{children}</div>

      {diType || patterns.length > 0 ? <p style={{
    fontSize: '0.85rem',
    color: '#6b7280',
    marginBottom: 0
  }}>
          {diType ? <>
              See the <a href={`/references/${diType}`}>{diType}</a> reference.{' '}
            </> : null}
          {patterns.length > 0 ? <>
              Accepts a <a href={`/documentation/placeholders-and-patterns/patterns#${patterns[0]}`}>pattern</a>.
            </> : null}
        </p> : null}
    </div>;
};

Renames the field names in your data while keeping the values intact. You point at the keys you want to work on with an accessor, then choose one or more conversions that rewrite each name. When a name changes, its value moves to the new name. Use this when the incoming system labels fields differently from the one you are sending to, for example turning `product_id` into `sku`. Keys whose names the conversions leave unchanged stay exactly as they were.

This documentation describes: [Schema](/schemas/transformer/key-mapper)

## Fields

<FormField property="accessor" label="Accessor" required diType="accessor">
  Selects which keys the renaming applies to. You pick a way of pointing at data, for example all keys at the top level or the keys inside a specific block, and each matched key is run through the conversions below. See [Accessors](/references/accessor) for the available options.
</FormField>

<FormField property="mappers" label="Mappers" diType="mapper">
  The list of conversions applied to each matched key name, such as mapping a name to a new one or replacing characters. Add several and they run in the order you list them, each working on the result of the one before. When the result differs from the original name, the value moves to the new name. Leave it empty to make no change.
</FormField>

<FormField property="stripEnclosures" label="Strip enclosures from keys">
  On by default. When a key name contains a dot it is normally wrapped in quotes so the dot is treated as part of the name rather than a path separator, for example `"product.name"`. With this on, those quotes are removed before the conversions see the name, which helps when a conversion matches against the start of a name or uses pattern matching that the quotes would interfere with.
</FormField>

## Sample data

| Field    | Value                                                                       |
| -------- | --------------------------------------------------------------------------- |
| Accessor | Pattern accessor matching `*` (all top-level keys)                          |
| Mappers  | Map value using dictionary: `product_id` to `sku`, `product_name` to `name` |

Input:

```json theme={null}
{
    "product_id": "A1",
    "product_name": "Wool scarf",
    "price": 49.95
}
```

Output:

```json theme={null}
{
    "price": 49.95,
    "sku": "A1",
    "name": "Wool scarf"
}
```

Each renamed value moves to its new field name, while `price` keeps its name and stays in place.

```json Configuration theme={null}
{
  "prototype": "key-mapper",
  "parameters": {
    "accessor": {
      "prototype": "pattern",
      "parameters": { "pattern": "*" }
    },
    "mappers": [
      {
        "prototype": "dictionary-map",
        "parameters": {
          "map": [
            ["product_id", "sku"],
            ["product_name", "name"]
          ]
        }
      }
    ]
  }
}
```
