Skip to content
Docs

Transformer

Transformer is the most versatile data-shaping node. You write a template, the expression engine resolves it against the run’s context, and the node emits the result. Use it to compose a new document from multiple sources (upstream output, the flow’s start payload, key-value entries, secrets) in a single step. You find it on the node picker’s Transform & data shelf.

The Transformer node's settings form, with the fields described below
The Transformer node's settings form, with the fields described below
FieldTypeDefaultDescription
Template (template)string ✦ (required) — A JSON template with embedded expressions that builds this node’s output from upstream data.

Fields marked ✦ accept expressions.

Try this node — run it once against your own workspace, with your credentials, without building a flow first.

The preferred way to write a Transformer template is an @json block. The block contains valid JSON; quoted "$.path" strings are resolved as JSONPath queries, and each value keeps its native JSON type (string, number, boolean, array, object, null).

Scoped to $prev, every path resolves against the upstream node’s output:

@json($prev)
{
"invoiceId": "$.orderId",
"customerEmail": "$.customer.email",
"subtotal": "$.total",
"firstTag": "$.tags[0]",
"taxable": "$.flags.taxable",
"customer": "$.customer"
}
@endjson

Without an argument, @json exposes every bound variable by its top-level name, so one document can combine sources:

@json
{
"orderId": "$.prev.orderId",
"region": "$.start.region",
"lastCursor": "$.kv.lastSyncCursor"
}
@endjson

The body of an @json block is strict JSON: echo tags and directives inside it fail to compile. To include a computed value, skip the block and write the document as raw text instead (next section). See How-to: Use expressions for the full @json reference, including spread ("...$.path") and per-item mappers.

When the output is not JSON (a URL, a free-text message), or a value must be computed inline, write the template as raw text with echo tags:

https://api.example.com/v1/orders/{{ $prev->id }}?since={{ $kv->lastSyncCursor }}

When raw text builds JSON, emit values with {!! json_encode(...) !!} so quotes are not HTML-escaped on the way through:

{
"userId": {!! json_encode($prev->id) !!},
"insertedAt": {!! json_encode(now()->toIso8601String()) !!}
}

Loops and conditions work in raw templates too. The Transformer — @foreach + @if template in the gallery filters and reshapes an item list:

@php $active = array_values(array_filter($prev->items, fn($i) => $i->qty > 0)); @endphp
{
"orderId": "{{ $prev->orderId }}",
"lineCount": {{ count($active) }},
"lines": [@foreach($active as $item){"sku":"{{ $item->sku }}","subtotal":{{ $item->qty * $item->price }}}@if(! $loop->last),@endif@endforeach]
}

The node emits the resolved template as its output. An @json block produces the assembled JSON document; a raw template produces the text exactly as it resolved.

  • The resolved template becomes the output verbatim. Nothing checks that a document you meant as JSON parses as JSON, and one that does not reaches the next node as plain text, where $prev->field resolves to null.
  • The body of an @json block is strict JSON. To compute a value inline, write the document as a raw template instead.