DataToolsLab
JSON Tools

JSON Array to Object (keyBy)

Convert an array of objects into a keyed object map, and reverse.

Loading tool…

What is Array → Object?

Two directional modes: 'keyBy' indexes an array of objects by a chosen field (e.g. id), producing a map. 'Reverse' converts a keyed object back into an array with a _key field.

How it works

In keyBy mode, each object's value at the chosen key becomes the key in the output map. In reverse mode, each key in the input object becomes a _key field in the output array.

  1. Paste data and choose mode. Paste an array for keyBy or an object for reverse. Pick the mode and key field.
  2. Read the result. The converted output appears instantly. Copy or download.

Examples

keyBy id

[{id:'a',name:'Alice'},{id:'b',name:'Bob'}] → {a:{id:'a',name:'Alice'},b:{id:'b',name:'Bob'}}

Common mistakes

Duplicate keys

If multiple objects share the same key value, later objects overwrite earlier ones.

Alternatives

JSON Tree Viewer

For exploring nested structures without conversion.

Frequently asked questions

What happens to null key values?

Objects with null/undefined for the key field are excluded from the output.

Online