# From Pairs

Convert array of key-value pairs to object using lodash _.fromPairs

> Canonical page: https://elysiatools.com/en/tools/from-pairs

- **Category:** Data Processing

- **Keywords:** array, object, pairs, convert, transform, lodash

## Overview

Convert an array of key-value pairs into a single object.

## Features:
- Accepts arrays of [key, value] pairs
- Creates an object from the pairs
- Handles various data types for values
- Supports string, number, and symbol keys
- Uses lodash _.fromPairs for reliable conversion

## Examples:
- Input: [["a", 1], ["b", 2]] → Output: {a: 1, b: 2}
- Input: [["name", "John"], ["age", 30]] → Output: {name: "John", age: 30}
- Input: [[1, "one"], [2, "two"]] → Output: {1: "one", 2: "two"}

## Use Cases:
- **Object Construction**: Build objects from pair arrays
- **Data Transformation**: Convert tabular data to object format
- **Configuration Building**: Create config objects from key-value lists
- **Data Import**: Convert imported pair arrays to objects

## Inputs

- **Key-Value Pairs** (textarea): Enter a valid JSON array of \[key, value\] pairs

## When to use

- When you have data in a tabular or list format and need to convert it to an object for programming use.
- When building configuration objects from key-value pairs, such as settings or parameters.
- When importing data from sources that output arrays of pairs, like APIs or CSV files, and require an object structure.

## How it works

- Input a valid JSON array of \[key, value\] pairs into the tool's text area.
- The tool processes the array using lodash's _.fromPairs method to ensure accurate conversion.
- It outputs a single JavaScript object where each pair becomes a property with the key as the name and value as the data.
- The conversion supports various data types for keys, including strings, numbers, and symbols, and handles diverse value types.

## Use cases

- Converting CSV or spreadsheet data exported as key-value pairs into a JavaScript object for application logic.
- Creating configuration objects from environment variables or settings lists in development workflows.
- Transforming API responses that return arrays of pairs into usable objects for data processing or display.

## Frequently asked questions

### What input format does the tool accept?

It accepts a valid JSON array of [key, value] pairs, such as [["a", 1], ["b", 2]].

### Can it handle non-string keys?

Yes, it supports string, number, and symbol keys as per lodash _.fromPairs functionality.

### What happens if the input is invalid?

The tool will return an error or empty output if the input is not a valid JSON array of pairs.

### Is there a limit to the number of pairs?

No specific limit is enforced, but performance may vary with very large arrays based on system resources.

### Does it support nested objects or arrays as values?

Yes, values can be any data type, including nested objects or arrays, as long as the input is valid JSON.

## Related tools

- [Assign Object](https://elysiatools.com/en/tools/assign-object): Assign source properties to a target object using lodash _.assign
- [Chunk Array](https://elysiatools.com/en/tools/chunk-array): Split array into chunks of specified size using lodash _.chunk
- [Compact Array](https://elysiatools.com/en/tools/compact-array): Remove falsey values from array using lodash _.compact
- [Defaults Object](https://elysiatools.com/en/tools/defaults-object): Apply default values to an object using lodash _.defaults
- [Drop Items](https://elysiatools.com/en/tools/drop-items): Drop first N items from array using lodash _.drop
- [Drop Right Items](https://elysiatools.com/en/tools/drop-right-items): Drop last N items from array using lodash _.dropRight
- [Drop While](https://elysiatools.com/en/tools/drop-while): Drop items from array while predicate is true using lodash _.dropWhile
- [Fill Array](https://elysiatools.com/en/tools/fill-array): Fill array with value from start to end index using lodash _.fill

## Samples

- [Grafana Advanced Application Samples](https://elysiatools.com/en/samples/grafana-samples): Comprehensive Grafana samples covering advanced dashboard design, alerting configurations, data source integrations, and plugin development
- [QR Code Samples](https://elysiatools.com/en/samples/qrcode-samples): Sample QR code images for testing QR code reading and generation tools
- [JWT Samples](https://elysiatools.com/en/samples/jwt-samples): Comprehensive JWT examples from basic token structure to advanced security implementations
- [PDF Samples](https://elysiatools.com/en/samples/pdf-samples): Generated PDF samples from tools dated 2026-02-01 to 2026-02-10
