> ## Documentation Index
> Fetch the complete documentation index at: https://docs.fetchhive.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Data Transform

> Reshape workflow data by building rows, concatenating arrays, or flattening an array without calling an external service

Use **Data Transform** when you need to reshape existing workflow output before another step reads it.

Data Transform does not call an external service. It is useful before **Google Sheets**, **Airtable**, **Custom API**, and follow-up **Iteration** steps.

## Configuration

| Option          | Required           | Description                                                                           |
| --------------- | ------------------ | ------------------------------------------------------------------------------------- |
| Name            | No                 | Label for the step in the workflow canvas.                                            |
| Mode            | Yes                | The transform to run. Choose **Build Rows**, **Concat Arrays**, or **Flatten Array**. |
| Fields          | Build Rows only    | Output object keys and their source values.                                           |
| Sources         | Concat Arrays only | Array values to append into one array.                                                |
| Source Value    | Flatten Array only | One array value to flatten by one level.                                              |
| Mismatch Policy | Build Rows only    | How to handle arrays with different lengths.                                          |

Add this step from the **Utilities** group in **Search steps...**.

## Modes

### Build Rows

Use **Build Rows** to zip arrays by index into an array of objects.

Each field has a **Key** and **Source Value**. The key becomes an object property. The source can be a whole variable reference such as `{{tool_names}}` or `{{step_3.output}}`, or a static value.

Array source values are read by index. Static scalar values repeat for every row.

Example:

```json theme={null}
{
  "tool_names": ["Exa", "Airtable"],
  "search_contexts": ["Search context for Exa", "Search context for Airtable"]
}
```

Build Rows fields:

```json theme={null}
[
  { "key": "tool_name", "value": "{{tool_names}}" },
  { "key": "search_context", "value": "{{search_contexts}}" },
  { "key": "workspace", "value": "Fetch Hive" }
]
```

Output:

```json theme={null}
[
  {
    "tool_name": "Exa",
    "search_context": "Search context for Exa",
    "workspace": "Fetch Hive"
  },
  {
    "tool_name": "Airtable",
    "search_context": "Search context for Airtable",
    "workspace": "Fetch Hive"
  }
]
```

Use **Mismatch Policy** when array lengths differ:

| Policy      | Behavior                                                                          |
| ----------- | --------------------------------------------------------------------------------- |
| Pad null    | Uses the longest array and fills missing values with `null`. This is the default. |
| Strict fail | Fails the step if array lengths do not match.                                     |
| Truncate    | Uses the shortest array length.                                                   |

### Concat Arrays

Use **Concat Arrays** to append multiple arrays into one longer array.

Each source must resolve to an array. If a source resolves to a string, object, number, or boolean, the step fails.

Example sources:

```json theme={null}
[
  { "value": "{{step_2.output}}" },
  { "value": "{{step_3.output}}" }
]
```

If those values are `["a", "b"]` and `["c"]`, the output is:

```json theme={null}
["a", "b", "c"]
```

### Flatten Array

Use **Flatten Array** to flatten one array by one level.

Nested array elements expand. Non-array elements stay in place.

Example source:

```json theme={null}
[[1, 2], 3, [4]]
```

Output:

```json theme={null}
[1, 2, 3, 4]
```

## Output

Data Transform stores its result at:

```text theme={null}
{{STEP_IDENTIFIER.output}}
```

For **Build Rows**, the output is an array of objects. This shape works well with integration steps that expect records or rows.

For **Concat Arrays** and **Flatten Array**, the output is an array that later steps can iterate over.

## Notes

* Source values should be whole placeholders such as `{{step_2.output}}`, or static scalar values.
* Mixed template strings such as `Research for {{tool_names}}` are not supported in Data Transform V1.
* Data Transform preserves arrays and objects as structured JSON for downstream steps.
* Data Transform is a free utility step.

See also: [Google Sheets](../integrations/google-sheets), [Airtable](../integrations/airtable), [Custom API](custom-api), and [Testing and Iteration](../../testing-and-iteration)
