# Merge

> Combine up to eight inputs into one JSON object keyed by port, when any or all have arrived.

Source: https://docs.tune.toys/nodes/data.merge/

Merge gathers up to eight data values into one JSON object, `{ "a": …, "b": … }`, keyed by the input each value arrived on.

## What it does

Each input `a` to `h` keeps its newest value. When Merge emits, `value` carries an object with one key per cabled input that has a value, and `trigger` fires once. A data input takes one cable, so Merge is also how several sources meet in one place.

## When to use it

Use it to build a JSON context for an [LLM chat](https://docs.tune.toys/nodes/ai.chat/), to log several values on one line, or to collect readings before a [Convert](https://docs.tune.toys/nodes/data.convert/) template turns them into a sentence.

## Ports

<!-- ports:start -->

| Port      | Direction | Signal         | Lanes |
| --------- | --------- | -------------- | ----- |
| `a`       | Input     | Data (any)     | 1     |
| `b`       | Input     | Data (any)     | 1     |
| `c`       | Input     | Data (any)     | 1     |
| `d`       | Input     | Data (any)     | 1     |
| `e`       | Input     | Data (any)     | 1     |
| `f`       | Input     | Data (any)     | 1     |
| `g`       | Input     | Data (any)     | 1     |
| `h`       | Input     | Data (any)     | 1     |
| `value`   | Output    | Data (json)    | 1     |
| `trigger` | Output    | Data (trigger) | 1     |

<!-- ports:end -->

## Parameters

<!-- parameters:start -->

| Parameter | Label | Range  | Default | Unit | Scale  | Notes                                                                                           |
| --------- | ----- | ------ | ------- | ---- | ------ | ----------------------------------------------------------------------------------------------- |
| `when`    | When  | 0 to 1 | 0       |      | linear | Emit on every new input, or only once every connected input has a value. Choices: 0 Any, 1 All. |

<!-- parameters:end -->

### When (`when`)

Any emits whenever any input changes, with whatever values have arrived so far. All waits until every cabled input has a value, then emits on each change after that.

## Tips

- Only cabled ports appear in the object; leave unused letters free.
- Use All when the downstream node needs every field, for example a template with several pointers.

## See also

[Convert](https://docs.tune.toys/nodes/data.convert/), [LLM chat](https://docs.tune.toys/nodes/ai.chat/), [Console log](https://docs.tune.toys/nodes/log.console/), [Data cables](https://docs.tune.toys/concepts/data-cables/).
