# Expression functions

> **About this page**
>
> - Kind: Reference
> - Summary: Lists the functions an expression can call, such as format, contains, startsWith, toJSON and fromJSON, with their arguments and results.
> - Last changed: 2026-12-01
> - Page: https://docs.swale.io/reference/expression-functions
> - 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 lists every built-in function available inside `${{...}}` expressions. Function names are not case-sensitive. Calling a function this page does not list, or giving a function more or fewer arguments than its signature below shows, is refused when the workflow or task definition holding the expression is uploaded or imported.

## contains

```
contains(value, searchValue)
```

Returns `true` if `value` contains `searchValue`, ignoring case.

- When `value` is an **array**, checks whether any element, read as text, equals `searchValue`.
- Otherwise, checks whether `searchValue` is a substring of `value`, both read as text.

Inputs and task outputs are text, so read an array from one with `fromJSON` first. On the raw text, `contains` looks for a substring.

**Examples**

```yaml
# String containment
condition: ${{contains(inputs.name, 'admin')}}

# Array containment
condition: ${{contains(fromJSON(tasks.list.outputs.tags), 'release')}}
```

---

## startsWith

```
startsWith(value, prefix)
```

Returns `true` if `value` starts with `prefix`, ignoring case. Both arguments are read as text, with null as an empty string.

**Example**

```yaml
condition: ${{startsWith(inputs.path, '/data/')}}
```

---

## endsWith

```
endsWith(value, suffix)
```

Returns `true` if `value` ends with `suffix`, ignoring case. Both arguments are read as text, with null as an empty string.

**Example**

```yaml
condition: ${{endsWith(inputs.filename, '.csv')}}
```

---

## format

```
format(template, arg0, arg1, ...)
```

Replaces positional placeholders `{0}`, `{1}`, … in `template` with the arguments that follow it, read as text. Returns the formatted string.

- `{0}` is the first argument after the template, `{1}` the second, and so on. A placeholder can appear more than once, in any order.
- A placeholder with no matching argument is left as written. Anything else between braces, or a `{` that is never closed, is an error.
- Escaped braces `{{` and `}}` produce a literal `{` or `}`.

**Examples**

```yaml
args:
  message: ${{format('Hello, {0}! You have {1} items.', inputs.name, inputs.count)}}
  # Escaped braces
  label: ${{format('{{literal braces}}')}} # produces: {literal braces}
```

---

## join

```
join(array)
join(array, separator)
```

Concatenates the elements of `array`, each read as text, into a single string, with `separator` inserted between them. The separator defaults to a comma when omitted. A value that is not an array is returned as text, unchanged.

**Examples**

```yaml
args:
  csv: ${{join(fromJSON(tasks.list.outputs.items))}}
  spaced: ${{join(fromJSON(tasks.list.outputs.items), ' ')}}
```

---

## toJSON

```
toJSON(value)
```

Serializes `value` to compact JSON. A string becomes a quoted, escaped JSON string, which makes `toJSON` the way to place a value inside a JSON document. An array or object needs no `toJSON` when it is the whole result of a `${{...}}` block, which already writes it as compact JSON.

**Example**

```yaml
args:
  payload: '{"name": ${{toJSON(inputs.name)}}}'
```

With the input `Ann`, `payload` is `{"name": "Ann"}`.

---

## fromJSON

```
fromJSON(jsonString)
```

Parses a JSON string and returns the resulting value. Use it to read an array or object from an input or a task output, which are always text.

**Example**

```yaml
args:
  first_item: ${{fromJSON(tasks.fetch.outputs.json_list)[0]}}
```

If `jsonString` is not valid JSON, including an empty value such as an output that was never written, the expression fails, and so does the task that uses it.

---

## Related pages

- [Expression language reference](https://docs.swale.io/reference/expression-language.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)
