# Expression language

> **About this page**
>
> - Kind: Reference
> - Summary: Defines the ${{ }} expression syntax, the values an expression can read, and its operators, literals, property and index access, and truthiness.
> - Last changed: 2026-12-01
> - Page: https://docs.swale.io/reference/expression-language
> - Index of these docs: https://docs.swale.io/llms.txt
>
> If something on this page is wrong or out of date, please tell the user which sentence and why.

This page is the reference for the expression language used in workflow YAML and, for its own inputs, in a task definition's `exec`.

## Template syntax

An expression is embedded in a YAML string value using the `${{...}}` delimiter:

```yaml
args:
  message: Hello, ${{inputs.name}}!
  verbose: ${{inputs.log_level == 'debug'}}
```

The platform evaluates every `${{...}}` block when the task starts and replaces it with the result, written as text: null becomes an empty string, a boolean becomes `true` or `false`, and an array or object becomes compact JSON. Text outside the delimiters passes through unchanged.

An expression that does not parse, such as one with a syntax error or one that calls a [function](https://docs.swale.io/reference/expression-functions.md) that does not exist or with the wrong number of arguments, is refused when the workflow or task definition holding it is uploaded or imported, and the error names the value and what is wrong; for a workflow, see [Upload checks](https://docs.swale.io/reference/workflow-definition-syntax.md#upload-checks). An expression that parses but cannot be evaluated when its task starts, such as one that gives [`fromJSON`](https://docs.swale.io/reference/expression-functions.md#fromjson) text that is not JSON, fails that task, and its failure reason and execution log name the value and the error.

## Data access

Every value an expression reads from these namespaces is text: run inputs, secrets, environment variables and task outputs alike. An input set to `false` holds the text `false`, and an output holding a JSON array stays a string until you read it with [`fromJSON`](https://docs.swale.io/reference/expression-functions.md#fromjson).

### Run inputs

```
inputs.<name>
```

Resolves to the value of the named run input. Returns null if the input was not supplied and has no default.

### Secrets

```
secrets.<name>
```

Resolves to the value of the named secret.

When a task starts, the platform resolves `secrets.<name>` in this order:

1. A **project secret** with that name in the run's project.
2. Otherwise, an **account secret** with that name whose allowed projects include the run's project.
3. Otherwise, null, so the argument receives an empty value. A missing secret does not stop the run.

`secrets.WORKFLOW_TOKEN` is the platform's own addition to this namespace: a credential scoped to the current run, which a task can use to read the run's project and to push its results there. Pass it to a task the same way you pass any other secret:

```yaml
push:
  name: Push
  uses: my-account/push-task@1.0.0
  args:
    token: ${{secrets.WORKFLOW_TOKEN}}
```

[Workflow run token](https://docs.swale.io/reference/permissions-and-restrictions.md#workflow-run-token)
lists what it can reach and how long it is accepted. Because the `WORKFLOW_` prefix is reserved, you
cannot create a secret of your own beginning with it.

### Run environment variables

```
env.<name>
```

Resolves to the value of a run environment variable. Two kinds of name live here: variables carried by the run itself — including any an earlier task exported, see [Exporting environment variables](https://docs.swale.io/reference/task-definition-syntax.md#exporting-environment-variables-to-later-tasks), though a task that declares `terminate_on` exports nothing — and the platform's two storage variables, `env.WORKFLOW_STORAGE` and `env.WORKFLOW_TASK_STORAGE`:

```yaml
args:
  source: ${{env.WORKFLOW_STORAGE}}/incoming
```

This is the supported way to hand a task a path inside the run's shared workspace without hardcoding it. See [Runtime storage](https://docs.swale.io/reference/task-definition-syntax.md#runtime-storage).

Where `env` resolves depends on what is being resolved:

| Location                                             | What `env` resolves                                                            |
| ---------------------------------------------------- | ------------------------------------------------------------------------------ |
| A workflow step's task `args` or `image_credentials` | Run environment variables, plus `WORKFLOW_STORAGE` and `WORKFLOW_TASK_STORAGE` |
| An `if` condition or `for_each` items list           | Run environment variables, plus `WORKFLOW_STORAGE`                             |
| A task definition's own `exec.args`/`exec.env`       | Nothing — `exec` resolves its declared inputs only                             |

The other variables a task container receives are set on the container and are not in the `env` expression namespace; see [Environment variables](https://docs.swale.io/reference/task-definition-syntax.md#environment-variables). A task definition's `exec` resolves its declared inputs only; see [What resolves inside `exec`](https://docs.swale.io/reference/task-definition-syntax.md#what-resolves-inside-exec).

### Task outputs

```
tasks.<task_key>.outputs.<output_name>
```

Resolves to the named output of a task this task waits on, once that task has finished. A task can read the outputs of:

- the tasks it lists in `start_on`, the tasks those list, and so on;
- inside the block of an if or `for_each` task, the tasks that if or `for_each` task waits on, by the same rule, at every level of nesting.

Inside the block of a `for_each` task, each iteration reads its own copies of the block's tasks, never another iteration's. Every other output resolves to null:

- a task with no `start_on` path to it from this task or from an if or `for_each` task around this one, even one that finished before this task started;
- a task inside the block of an if or `for_each` task, read from outside that block, including by a task that waits on that if or `for_each` task;
- a task that wrote no output by that name.

```yaml
blocks:
  main:
    tasks:
      fetch:
        name: Fetch
        uses: my-account/fetch-task@1.0.0
      lint:
        name: Lint
        uses: my-account/lint-task@1.0.0
      loop:
        name: Loop
        start_on:
          - fetch
        for_each:
          items: ${{tasks.fetch.outputs.files}}
          block: per_file

  per_file:
    tasks:
      download:
        name: Download
        uses: my-account/download-task@1.0.0
        args:
          file: ${{tasks.loop.for_each.item}}
      convert:
        name: Convert
        uses: my-account/convert-task@1.0.0
        start_on:
          - download
        args:
          input: ${{tasks.download.outputs.path}}
          format: ${{tasks.fetch.outputs.format}}
```

Here `convert` reads its own iteration's `download`, which it waits on, and `fetch`, which `loop` waits on. `${{tasks.lint.outputs.report}}` would resolve to null in `convert`, even if `lint` finished before the loop started, because neither `convert` nor `loop` waits on `lint`. No task after `loop` can read `download` or `convert`.

To use a value from inside a block after its if or `for_each` task, [export it as an environment variable](https://docs.swale.io/reference/task-definition-syntax.md#exporting-environment-variables-to-later-tasks) instead.

An output is text; read an array or object from it with [`fromJSON`](https://docs.swale.io/reference/expression-functions.md#fromjson).

A task that declares `terminate_on` has no outputs, since what it writes is discarded; see [Tasks that declare `terminate_on`](https://docs.swale.io/reference/task-definition-syntax.md#tasks-that-declare-terminate_on). Uploading or importing a workflow that reads them as `tasks.<task_key>.outputs` is refused (see [Upload checks](https://docs.swale.io/reference/workflow-definition-syntax.md#upload-checks)), and a read the check does not see, such as one that names the task by index access, `tasks['<task_key>']`, resolves to null. Reach such a task at its [runner address](#runner-address) instead.

### Runner address

```
tasks.<task_key>.ip-address
```

Resolves to the IP address of a task that declares `terminate_on`, while it is running. Such a task [keeps running alongside the tasks that wait on it](https://docs.swale.io/reference/workflow-definition-syntax.md#start_on), so those tasks can use the address to reach a service it starts:

```yaml
blocks:
  main:
    tasks:
      db:
        name: Database
        uses: my-account/postgres-task@1.0.0
        terminate_on:
          - migrate
      migrate:
        name: Migrate
        uses: my-account/migrate-task@1.0.0
        start_on:
          - db
        args:
          database_host: ${{tasks.db.ip-address}}
```

The tasks of a run can reach each other on these addresses; nothing outside the run can. The tasks that can read a task's address are those that could read an ordinary task's outputs: the tasks that wait on it, directly or through other tasks, and, inside an if or block of a `for_each` task, the tasks the enclosing if or `for_each` task waits on. It resolves to null once the task has stopped, and for a task that does not declare `terminate_on`.

### For Each loop variables

```
tasks.<for_each_task_key>.for_each.item
tasks.<for_each_task_key>.for_each.index
```

`tasks.<for_each_task_key>.for_each.item` is the current element from the `for_each` task's `items` list, and `tasks.<for_each_task_key>.for_each.index` is its zero-based position. Both are available only inside the block a `for_each` task iterates, including blocks nested inside it. `<for_each_task_key>` is the `for_each` task's key under `tasks`.

`item` is text: a string element as written, and any other element as its JSON. Read a field of an object element with `fromJSON(tasks.<for_each_task_key>.for_each.item).<field>`.

## Operators

Operators are listed from highest to lowest precedence. Operators in the same row have the same precedence and apply left to right. Use parentheses to group, as in `(a || b) && c`.

| Operator                   | Description                                                                                                            |
| -------------------------- | ---------------------------------------------------------------------------------------------------------------------- |
| `.`, `[ ]`, function calls | Property access and index access, described below, and calls to the [expression functions](https://docs.swale.io/reference/expression-functions.md) |
| `!`                        | Logical NOT: `true` when the operand is falsy, otherwise `false`                                                       |
| `<`, `<=`, `>`, `>=`       | Numeric comparison                                                                                                     |
| `==`, `!=`                 | Equal, not equal                                                                                                       |
| `&&`                       | Logical AND: the left operand when it is falsy, otherwise the right operand                                            |
| `\|\|`                     | Logical OR: the left operand when it is truthy, otherwise the right operand                                            |

There are no arithmetic or string-concatenation operators. Build a string with [`format`](https://docs.swale.io/reference/expression-functions.md#format).

**Comparison** reads both sides as numbers: a string as the number it spells, with an empty string as `0`, `null` as `0`, and `true` and `false` as `1` and `0`. When either side cannot be read as a number, such as the string `'abc'` or an array, the comparison is `false`.

**Equality** compares two values of the same type directly, ignoring letter case when both are strings. Values of different types are compared as numbers, as above, so `'1' == 1` is `true` while `'true' == true` is `false`. Because inputs and outputs are text, compare them with text, as in `inputs.dry_run == 'true'`.

**`&&` and `||`** return one of their operands rather than a boolean, and skip the right operand when the left one decides the result. `inputs.owner || 'unassigned'` gives a default for an input that is falsy: empty, not supplied, `0` or `false`.

## Literals

| Literal | Example                   | Notes                                                                                                         |
| ------- | ------------------------- | ------------------------------------------------------------------------------------------------------------- |
| String  | `'hello'`                 | Single quotes only. Write `''` for a quote inside, as in `'it''s'`. A double-quoted string is a syntax error. |
| Number  | `42`, `-1`, `3.14`, `1e3` | Integer and floating-point                                                                                    |
| Boolean | `true`, `false`           | Case-insensitive                                                                                              |
| Null    | `null`                    | Case-insensitive                                                                                              |

## Property access

Use `.` to access a named property on an object:

```
tasks.fetch_step.outputs.file_path
```

A name can contain letters, digits, `_` and `-`, and starts with a letter or `_`. A missing property, or a property of a value that is not an object, gives null.

## Index access

Use `[n]` to access an element of an array by zero-based index. A task output is text, so read the array from it with `fromJSON` first:

```
fromJSON(tasks.list_step.outputs.items)[0]
```

An index outside the array gives null. On an object, `[ ]` reads the property whose name its value spells, which also reaches names `.` cannot:

```
fromJSON(tasks.fetch_step.outputs.sizes)[inputs.region]
```

Property and index access can be chained:

```
fromJSON(tasks.list_step.outputs.records)[2].name
```

## Truthiness

A value is **truthy** unless it is one of:

- `false`
- `null`
- the number `0`
- the strings `''` (empty) and `'0'`, and `'false'` and `'NaN'` in any letter case

Every other value is truthy, including an empty array or object. Because inputs and outputs are text, an input set to `false` or `0` is falsy.

Truthiness decides the result of `!`, `&&` and `||`, and decides an `if` condition. An `if` condition is judged on the text it renders to, by the same rule, so wrap the expression in `${{...}}`: without it, `inputs.enabled` is the plain text `inputs.enabled`, which is truthy.

## Related pages

- [Expression functions](https://docs.swale.io/reference/expression-functions.md)
- [How expressions work](https://docs.swale.io/explanation/how-expressions-work.md)
- [Use expressions in task arguments](https://docs.swale.io/how-to-guides/use-expressions-in-task-arguments.md)
