# Expression function reference (/docs/organisers/overlays/expression-functions)

Reference for operators, built-in functions, format patterns, and limits in design overlay expressions.

This reference lists every operator, built-in function, format pattern, and
ceiling supported by Strave design overlay expressions. Every function is pure
and deterministic, so the same live match data always produces the same output
in the editor and on air.

<Callout type="info">
Design overlay expressions are in preview as part of Phase 3 of the graphics
roadmap. Signatures and available functions may change before general release.
</Callout>

## Operators and precedence [#operators-and-precedence]

Operators are evaluated from top (highest precedence) to bottom (lowest
precedence). Use parentheses `(...)` whenever you want to group an expression
explicitly.

| Priority | Operators            | Purpose                                    | Example                                               |
| -------- | -------------------- | ------------------------------------------ | ----------------------------------------------------- |
| 1        | `.field`, `[index]`  | Property lookup and zero-based list index  | `match.maps[1].winner`                                |
| 2        | `-x`                 | Numeric negation                           | `-item.roundDifferential`                             |
| 3        | `\|`                 | Pipe value as first argument to a function | `team.a.name \| upper`                                |
| 4        | `*`, `/`, `%`        | Multiply, divide, remainder                | `match.bestOf / 2`                                    |
| 5        | `+`, `-`             | Add or concatenate text, subtract          | `index + 1`                                           |
| 6        | `??`                 | Fallback when left side is `null`          | `team.a.name ?? "TBD"`                                |
| 7        | `<`, `<=`, `>`, `>=` | Order comparison (numbers or text)         | `match.bestOf >= 3`                                   |
| 8        | `==`, `!=`           | Exact equality and inequality              | `item.status == "picked"`                             |
| 9        | `not`                | Boolean negation                           | `not item.current`                                    |
| 10       | `and`                | Boolean AND (short-circuits)               | `match.bestOf >= 3 and match.teams.a.score >= 2`      |
| 11       | `or`                 | Boolean OR (short-circuits)                | `item.status == "picked" or item.status == "decider"` |

Keep three operator rules in mind:

- `+` adds two numbers or joins two text values. It doesn't mix numbers and
  text. Convert the number first with `text(...)` or `format(...)`.
- Division or remainder by `0` returns `null` rather than an error.
- Boolean operators require boolean inputs (`true`, `false`, or `null`, where
  `null` acts as `false`). Use `and`, `or`, and `not` instead of `&&`, `||`, and
  `!`.

## Formatting functions [#formatting-functions]

Formatting functions turn numbers, timestamps, and durations into display text.
All formatting is independent of your operating system's locale so every OBS and
vMix machine renders the exact same output.

| Function         | Signature                                     | Description and example                                                                                                          |
| ---------------- | --------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------- |
| `format`         | `format(number, pattern)`                     | Formats a number with a pattern string. `format(0.742, "0.0%")` returns `"74.2%"`.                                               |
| `formatDate`     | `formatDate(timestampMs, pattern, timezone?)` | Formats a Unix millisecond timestamp. Defaults to `"UTC"`. `formatDate(match.scheduledAt, "HH:mm [UTC]")` returns `"19:30 UTC"`. |
| `formatDuration` | `formatDuration(ms, pattern?)`                | Formats a duration in milliseconds using `"mm:ss"` (default) or `"HH:mm:ss"`. `formatDuration(185000)` returns `"03:05"`.        |
| `ordinal`        | `ordinal(number)`                             | Returns the English ordinal form. `ordinal(1)` returns `"1st"`, `ordinal(12)` returns `"12th"`.                                  |
| `text`           | `text(value)`                                 | Converts a number, boolean, or colour to text. `text(match.teams.a.score)` returns `"2"`.                                        |

### Number format patterns [#number-format-patterns]

Pass a literal pattern string to `format(value, pattern)`:

- `0` prints a required digit, padding with zeros when needed (`format(7, "00")`
  returns `"07"`).
- `#` prints an optional digit, omitting leading or trailing zeros
  (`format(1.2, "0.0#")` returns `"1.2"`).
- `,` adds thousands grouping (`format(12500, "#,##0")` returns `"12,500"`).
- `+` at the start forces a `+` sign on positive numbers while leaving `0`
  unsigned (`format(14, "+0")` returns `"+14"`, `format(0, "+0")` returns `"0"`,
  `format(-3, "+0")` returns `"-3"`).
- `%` at the end multiplies by 100 and appends `%` (`format(0.684, "0.0%")`
  returns `"68.4%"`).

Numbers round half-away-from-zero (`format(1.235, "0.00")` returns `"1.24"`).

### Date and time patterns [#date-and-time-patterns]

Pass a literal pattern string and an optional IANA timezone name (such as
`"Europe/Berlin"` or `"America/New_York"`) to `formatDate`. Wrap literal text
inside square brackets so tokens aren't expanded (for example `"[UTC]"`).

| Token          | Output                          | Example            |
| -------------- | ------------------------------- | ------------------ |
| `YYYY` / `YY`  | 4-digit or 2-digit year         | `2026` / `26`      |
| `MMMM` / `MMM` | Full or 3-letter month name     | `November` / `Nov` |
| `MM` / `M`     | Zero-padded or unpadded month   | `11` / `11`        |
| `DD` / `D`     | Zero-padded or unpadded day     | `07` / `7`         |
| `dddd` / `ddd` | Full or 3-letter weekday        | `Friday` / `Fri`   |
| `HH` / `H`     | 24-hour clock (`00` to `23`)    | `19` / `9`         |
| `hh` / `h`     | 12-hour clock (`01` to `12`)    | `07` / `7`         |
| `mm` / `ss`    | 2-digit minute or second        | `05` / `09`        |
| `A` / `a`      | Uppercase or lowercase meridiem | `PM` / `pm`        |
| `Z`            | Numeric UTC offset              | `+01:00` or `Z`    |

## Text functions [#text-functions]

Text functions count and slice by Unicode characters so accented letters and
symbols never split in half. All text functions return `null` when given `null`,
except `contains`, `startsWith`, and `endsWith` (which return `false`).

| Function     | Signature                            | Description and example                                                                                               |
| ------------ | ------------------------------------ | --------------------------------------------------------------------------------------------------------------------- |
| `upper`      | `upper(text)`                        | Converts text to uppercase. `upper("Bank")` returns `"BANK"`.                                                         |
| `lower`      | `lower(text)`                        | Converts text to lowercase. `lower("CLUBHOUSE")` returns `"clubhouse"`.                                               |
| `trim`       | `trim(text)`                         | Removes leading and trailing whitespace. `trim("  G2  ")` returns `"G2"`.                                             |
| `padStart`   | `padStart(value, length, fill?)`     | Pads text or a number on the left (default fill `" "`). `padStart(3, 2, "0")` returns `"03"`.                         |
| `padEnd`     | `padEnd(value, length, fill?)`       | Pads text or a number on the right (default fill `" "`). `padEnd("EU", 4, ".")` returns `"EU.."`.                     |
| `truncate`   | `truncate(text, maxLength, suffix?)` | Shortens text past `maxLength` and appends `suffix` (default `"..."`).                                                |
| `slice`      | `slice(text, start, end?)`           | Extracts characters from `start` (inclusive) to `end` (exclusive). Negative indices count from the end.               |
| `replace`    | `replace(text, search, replacement)` | Replaces every literal match of `search` with `replacement`.                                                          |
| `length`     | `length(text)`                       | Returns the character count. `length("BDS")` returns `3`.                                                             |
| `contains`   | `contains(text, needle)`             | Returns `true` when `text` contains `needle` (case-sensitive).                                                        |
| `startsWith` | `startsWith(text, prefix)`           | Returns `true` when `text` starts with `prefix`.                                                                      |
| `endsWith`   | `endsWith(text, suffix)`             | Returns `true` when `text` ends with `suffix`.                                                                        |
| `join`       | `join(textList, separator)`          | Joins non-null text entries with `separator`. `playday.casters \| join(" & ")` returns `"Demo Caster & Replay Desk"`. |

## Number functions [#number-functions]

Number functions propagate `null` except `min` and `max`, which return the
non-null value when only one side is missing.

| Function | Signature                  | Description and example                                                           |
| -------- | -------------------------- | --------------------------------------------------------------------------------- |
| `round`  | `round(number, decimals?)` | Rounds half-away-from-zero to `decimals` places (default `0`).                    |
| `floor`  | `floor(number)`            | Rounds down to the nearest integer. `floor(2.9)` returns `2`.                     |
| `ceil`   | `ceil(number)`             | Rounds up to the nearest integer. `ceil(match.bestOf / 2)` returns `2` for a Bo3. |
| `abs`    | `abs(number)`              | Returns the non-negative magnitude. `abs(-4)` returns `4`.                        |
| `clamp`  | `clamp(number, low, high)` | Keeps a number inside `[low, high]`. `clamp(scoreA, 0, 3)`.                       |
| `min`    | `min(a, b)`                | Returns the smaller of two numbers.                                               |
| `max`    | `max(a, b)`                | Returns the larger of two numbers.                                                |

## Colour literals and functions [#colour-literals-and-functions]

Write colour literals directly with `#RGB`, `#RRGGBB`, or `#RRGGBBAA` (for
example `#FF7700` or `#151A21CC`). Use colour functions to parse or adjust alpha
values:

| Function | Signature                | Description and example                                               |
| -------- | ------------------------ | --------------------------------------------------------------------- |
| `colour` | `colour(text)`           | Parses a hex colour string into a colour value, or `null` if invalid. |
| `alpha`  | `alpha(colour, opacity)` | Sets opacity between `0` and `1`. `alpha(branding.primary, 0.25)`.    |

## Conditional functions [#conditional-functions]

Conditionals only evaluate the branch that matches. Both branches must return
compatible types.

| Function | Signature                                           | Description and example                                                                                                                                                                             |
| -------- | --------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `if`     | `if(condition, thenValue, elseValue?)`              | Returns `thenValue` when `condition` is `true`, otherwise `elseValue` (or `null` when omitted). `if(match.bestOf >= 3, "SERIES", "BO1")`.                                                           |
| `switch` | `switch(value, case1, result1, ..., defaultValue?)` | Compares `value` against each case in order and returns the first matching result, or `defaultValue` (or `null` when omitted). `switch(item.status, "picked", "PICK", "banned", "BAN", "DECIDER")`. |

## List functions [#list-functions]

List functions work on catalog lists such as `match.maps`, `match.veto`, and
`playday.matches`. Field names (such as `"status"` or `"stats.kost"`) must be
literal strings so the editor can check them against the catalog.

| Function | Signature                        | Description and example                                                                                                                                                 |
| -------- | -------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `count`  | `count(list)`                    | Returns the number of items (`0` when `null`). `match.maps \| count`.                                                                                                   |
| `first`  | `first(list)`                    | Returns the first item, or `null` when empty. `playday.casters \| first`.                                                                                               |
| `last`   | `last(list)`                     | Returns the last item, or `null` when empty. `match.maps \| last`.                                                                                                      |
| `take`   | `take(list, n)`                  | Keeps at most the first `n` items. `playday.matches \| take(4)`.                                                                                                        |
| `skip`   | `skip(list, n)`                  | Drops the first `n` items. `event.standings \| skip(4) \| take(4)` (Planned).                                                                                           |
| `sort`   | `sort(list, field, direction?)`  | Stable sort by `field` with `"asc"` (default) or `"desc"`. Missing values always sort last. `match.maps \| sort("number", "desc")`.                                     |
| `filter` | `filter(list, field, op, value)` | Keeps items matching `op` (`"=="`, `"!="`, `"<"`, `"<="`, `">"`, `">="`, `"contains"`, `"startsWith"`, `"endsWith"`). `match.veto \| filter("status", "==", "picked")`. |
| `sum`    | `sum(list, field?)`              | Adds all non-null numbers for `field` (`0` when empty). `match.teams.a.players \| sum("stats.kills")` (Planned).                                                        |
| `avg`    | `avg(list, field?)`              | Averages all non-null numbers for `field` (`null` when empty). `match.teams.a.players \| avg("stats.kost")` (Planned).                                                  |
| `min`    | `min(list, field?)`              | Smallest non-null number for `field` (`null` when empty).                                                                                                               |
| `max`    | `max(list, field?)`              | Largest non-null number for `field` (`null` when empty).                                                                                                                |

Chain `filter` stages with pipes when you need multiple conditions:

```text
match.veto | filter("status", "==", "banned") | filter("team", "==", "a") | count
```

## Limits [#limits]

Strave enforces fixed limits on expressions so every overlay renders in under a
millisecond in OBS and vMix without blocking frames.

| Resource                                                    | Limit                            |
| ----------------------------------------------------------- | -------------------------------- |
| Single expression length                                    | 512 characters                   |
| Full text template length                                   | 2,048 characters                 |
| `{ ... }` blocks per text layer                             | 16                               |
| Pipe stages in one chain                                    | 8                                |
| Function or `switch` arguments                              | 21 (up to 10 cases plus default) |
| Items rendered by one repeat group                          | 64 (default cap: 32)             |
| Repeat group nesting depth                                  | 1 (no nested repeat groups)      |
| Output length of `padStart`, `padEnd`, `replace`, or `join` | 256 characters                   |

## Next steps [#next-steps]

- Read the walkthrough and Siege broadcast examples in
  [Design overlay expressions](/docs/organisers/overlays/expressions).
- Attach overlays to OBS or vMix in the
  [Overlay overview](/docs/organisers/overlays/overview).