---
title: dict.fromList() function
description: dict.fromList() creates a dictionary from a list of records with key and value properties.
url: https://docs.influxdata.com/flux/v0/stdlib/dict/fromlist/
estimated_tokens: 755
product: Flux
version: v0
---

# dict.fromList() function

-   Flux 0.97.0+
-   View InfluxDB support

`dict.fromList()` creates a dictionary from a list of records with `key` and `value` properties.

##### Function type signature

```js
(pairs: [{value: B, key: A}]) => [A:B] where A: Comparable
```

For more information, see [Function type signatures](/flux/v0/function-type-signatures/).

## Parameters

### pairs

(Required) List of records with `key` and `value` properties.

## Examples

### Create a dictionary from a list of records

```js
import "dict"

d =
    dict.fromList(
        pairs: [{key: 1, value: "foo"}, {key: 2, value: "bar"}],
    )// Returns [1: "foo", 2: "bar"]

```

#### Related

-   [Work with dictionaries](/flux/v0/data-types/composite/dict/)
