# JSON array rename keys

`json-array-rename-keys` · version 1.0.0 · JSON & JSONL · free, no key needed

Rename specific keys in each object in a JSON array.

**Use when you need to: json array rename keys · remap json keys in array · rename json fields.**

## Supported

- json array rename keys
- remap json keys in array
- rename json fields

## Not supported

- deep renaming

## Behavior

- Applies a key mapping to each object in the array.
- If a key exists in the object and is in the mapping, it is renamed to the new key.
- If the new key already exists in the object, the old key's value overwrites it.
- The order of keys in the output object is not guaranteed to be identical to the input.

## Input

- `array` (array of object, required): max items 10000
- `mapping` (object, required)

## Output

- `result` (array of object, required)
- `count` (integer, required)

## Limits

- max array items: 10000
- max output items: 10000
- max keys: 32

## Example

Request input:

```json
{
  "array": [
    {
      "a": 1,
      "b": 2
    },
    {
      "a": 3,
      "c": 4
    }
  ],
  "mapping": {
    "a": "id",
    "b": "value"
  }
}
```

Response:

```json
{
  "result": {
    "result": [
      {
        "id": 1,
        "value": 2
      },
      {
        "id": 3,
        "c": 4
      }
    ],
    "count": 2
  }
}
```

## How to call it

### MCP

Connect `https://computefirst.net/mcp` ([setup](/docs#connect)), then call `execute` with:

```json
{
  "id": "json-array-rename-keys",
  "version": "1.0.0",
  "input": {
    "array": [
      {
        "a": 1,
        "b": 2
      },
      {
        "a": 3,
        "c": 4
      }
    ],
    "mapping": {
      "a": "id",
      "b": "value"
    }
  }
}
```

### HTTP (no key)

```sh
curl -X POST https://computefirst.net/v1/tools/json-array-rename-keys/versions/1.0.0/execute \
  -H "Content-Type: application/json" \
  -d '{"array":[{"a":1,"b":2},{"a":3,"c":4}],"mapping":{"a":"id","b":"value"}}'
```

The machine-readable contract is at [/v1/tools/json-array-rename-keys/versions/1.0.0](/v1/tools/json-array-rename-keys/versions/1.0.0).

### CLI

```sh
node cli.mjs run json-array-rename-keys 1.0.0 --input input.json --base-url https://computefirst.net
```

Get the client at [/clients/cli/](/clients/cli/).

## Related tools

- [JSON array drop keys](/tools/json-array-drop-keys): Remove specific keys from each object in a JSON array.
- [JSON array project](/tools/json-array-project): Select specific keys from each object in a JSON array.
- [JSON array anti join](/tools/json-array-anti-join): Anti join two JSON arrays of objects on exact keys.
- [JSON array group by](/tools/json-array-group-by): Group an array of JSON objects by exact keys.
- [JSON array group count](/tools/json-array-group-count): Group an array of JSON objects by exact keys and return the count.
- [JSON array inner join](/tools/json-array-inner-join): Inner join two JSON arrays of objects on exact keys.
