On this page
Sommatic Docs
Open portal

Transform Data

Transforms the input payload using powerful JSONata expressions.

View as Markdown
Open in
Data Available data.transform Version 1.0.0 Execution: sync

Evaluates a JSONata expression against the incoming payload; the result replaces the payload.

This is the primary tool for data mapping and structural transformation logic within the workflow. It allows you to reshape, filter, and mathematically compute new values from the input JSON.

Features:

  • Full JSONata syntax support.
  • Access to the entire workflow context.
  • Capability to query and aggregate data.

Use Cases:

  • Mapping an API response to an internal model.
  • Filtering items from a list (e.g., items[price > 50]).
  • Calculating totals (e.g., $sum(items.price)).

How it works

  1. Resolves the config: {{ }} blocks inside expr are evaluated first by the Expression Engine; plain JSONata text is left untouched.
  2. Fails when expr is empty.
  3. If expr resolved to an object or array (a whole-value {{ }} returning data), that value is the result and JSONata is skipped.
  4. Otherwise compiles the string as JSONata 2 and evaluates it with the payload as root: order.total, $sum(items.price), { "id": order_id, "lines": $count(items) }.
  5. Returns the result as the new payload through out.

In a workflow

The node as it appears in a workflow file (draft_nodes[]), and the envelope of a successful run.

{
  "node_id": "node-shape-order",
  "label": "Shape order",
  "operator_slug": "data.transform",
  "operator_version": "1.0.0",
  "config": {
    "expr": "{ \"id\": order_id, \"total\": $sum(items.price), \"lines\": $count(items) }"
  }
}

Configuration

expr string Required Accepts expressions

The JSONata expression to evaluate. The result becomes the output payload.

Its configuration shows the shared execution settings, but this node does not apply retries (retryOnFail, maxTries) yet. continueOnFail is not applied by any node.

Behaviour in the code

What the implementation does with these keys beyond what the schema says.

expr
Expression Engine variables are not bound inside JSONata: $json.total evaluates to undefined. Use payload paths and JSONata built-ins ($now(), $sum, $map), or embed engine values with {{ }} in mixed text, which inserts their string form: { "run": "{{ $execution.id }}", "total": $sum(items.price) }. A failing {{ }} in mixed text becomes [ERROR: <message>] inside the expression.

Output ports

out default

The expression was evaluated.

Data
{
  "id": "ord_123",
  "total": 42.5,
  "lines": 2
}
error

expr is empty or JSONata failed.

Data
{
  "ok": false,
  "errors": [
    "Transform Error: Unexpected end of expression"
  ],
  "port": "error"
}

In expressions

What a later node can read from this node's output with $("Transform Data").item.json.<path> (write your node's label instead of Transform Data). Editor marks the paths the workflow editor suggests under Previous Nodes (the output contract); Worker marks the paths the worker really returns through out, from the output shown in Ports.

ExpressionEditorWorker
$("Transform Data").item.json.resultobjectThe worker does not return it: reads as undefined —
$("Transform Data").item.json.idstringNot suggested by the editor= "ord_123"—
$("Transform Data").item.json.totalnumberNot suggested by the editor= 42.5—
$("Transform Data").item.json.linesnumberNot suggested by the editor= 2—

— Editor: The editor suggests it, but the worker does not return it: it reads as undefined.

— Worker: The worker returns it but the editor does not suggest it: write it by hand. Keys inside objects can depend on your data or configuration (for example one key per label).

Errors

Message Port Cause and fix
Transformation expression is required error expr is missing, or its {{ }} resolved to an empty value.
Transform Error: <JSONata message> error JSONata syntax or runtime error, for example Unexpected end of expression.
Transform Error: path.charAt is not a function error A whole-value {{ }} returned a number or boolean, which is neither JSONata text nor data.

Input contract

payload object Optional

Output contract

result object Optional

Contracts (JSON Schema)

The definition exactly as the orchestrator declares it. All is the whole *.definition.js; compare it with the sections above to spot differences between the documentation and the schema. Use it to validate a node before you publish.

{
  "slug": "data.transform",
  "name": "Transform Data",
  "category": "data",
  "version": "1.0.0",
  "description": "Transforms the input payload using powerful JSONata expressions.\n\n  This is the primary tool for data mapping and structural transformation logic within the workflow. It allows you to reshape, filter, and mathematically compute new values from the input JSON.\n\n  **Features:**\n  - Full JSONata syntax support.\n  - Access to the entire workflow context.\n  - Capability to query and aggregate data.\n\n  **Use Cases:**\n  - Mapping an API response to an internal model.\n  - Filtering items from a list (e.g., `items[price > 50]`).\n  - Calculating totals (e.g., `$sum(items.price)`).",
  "capabilities": [
    "transform",
    "jsonata",
    "mapping",
    "utils"
  ],
  "config_schema": {
    "type": "object",
    "required": [
      "expr"
    ],
    "properties": {
      "expr": {
        "type": "string",
        "title": "Transformation Expression",
        "format": "expression",
        "description": "The JSONata expression to evaluate. The result becomes the output payload."
      },
      "execution": {
        "type": "object",
        "title": "Execution Settings",
        "properties": {
          "alwaysOutputData": {
            "type": "boolean",
            "title": "Always Output Data",
            "description": "Always output data, even on error (if configured).",
            "default": false
          },
          "retryOnFail": {
            "type": "boolean",
            "title": "Retry On Fail",
            "description": "Retry the execution if it fails.",
            "default": false
          },
          "maxTries": {
            "type": "integer",
            "title": "Max Retries",
            "description": "Number of retries.",
            "default": 3,
            "displayOptions": {
              "show": {
                "retryOnFail": [
                  true
                ]
              }
            }
          },
          "waitBetweenTries": {
            "type": "integer",
            "title": "Wait Between Retries (ms)",
            "default": 1000,
            "displayOptions": {
              "show": {
                "retryOnFail": [
                  true
                ]
              }
            }
          },
          "continueOnFail": {
            "type": "boolean",
            "title": "Continue On Fail",
            "description": "Do not crash workflow on error.",
            "default": false
          },
          "timeout_ms": {
            "type": "integer",
            "title": "Timeout (ms)",
            "description": "Max execution time for this node before it is killed, in milliseconds. Honored by long-running operators (e.g. OCR/extraction, inline code). Default 300000 (5 min).",
            "default": 300000
          }
        }
      }
    }
  },
  "input_contract_schema": {
    "type": "object",
    "description": "Any JSON payload.",
    "properties": {
      "payload": {
        "type": "object"
      }
    }
  },
  "output_contract_schema": {
    "type": "object",
    "description": "The result of the JSONata evaluation.",
    "properties": {
      "result": {
        "type": "object"
      }
    }
  },
  "ports": [
    {
      "port_id": "out",
      "label": "Output",
      "is_default": true,
      "description": "Transformation result"
    },
    {
      "port_id": "error",
      "label": "Error",
      "description": "Expression failed"
    }
  ],
  "execution_mode": "sync",
  "tags": [
    "transform",
    "jsonata",
    "map"
  ],
  "is_stateful": false,
  "publisher": {
    "identity": "org_link_loom",
    "profile": {
      "name": "Link Loom",
      "verified": true,
      "url": "https://me.veripass.com/link-loom",
      "logo_url": null
    }
  }
}

Execution

Execution
sync
Stateful
No
Retries (retryOnFail)
No
Capabilities
transformjsonatamappingutils
Tags
transformjsonatamap

Notes and limits

  • If the result is undefined (a path that matches nothing) or falsy, the engine stores the whole envelope { ok, port } as the output instead of the result.
  • The previous payload is replaced; reference earlier data with {{ $("Node").item.json.field }} in mixed text.
  • When the envelope has no data (or data is falsy), the engine stores the whole envelope as the node output: on error the next node receives { ok: false, errors: [...], port: "error" } as its payload.

Reviewed against the orchestrator code · 31e874b · 2026-11-26

Install agent tools

Give your coding agent the official Sommatic AI docs: skills, the docs MCP server and Markdown pages, so it never has to scrape the site.

Skills only. They do not update by themselves; run it again to refresh.

npx skills add https://docs.sommatic.ai
How agents read these docs