Docs / Template Filters
Template Filters
Transform values inline inside any {{variable}} text field — regex extraction, case conversion, fallbacks, and more — without dropping in a Code node.
Syntax
Filters are appended to a variable expression with a single pipe (|). Chain as many as you want. Arguments come after a colon (:), with string values in double quotes.
{{ subject | trim | replace:"Re: ":"" | upper }}
{{ phone | regex_match:"\d{3}-\d{4}" }}
{{ message | regex_match:"order: (\d+)":1 }} // capture group 1
{{ user.email || $trigger.email | lower }} // coalesce, then filter
{{ items | slice:0:5 }} // returns a real arrayNote: single | is a filter; double || is the existing coalesce operator (use first non-empty value). They compose — coalesce resolves first, then filters apply.
Regex filters
| Filter | Example | Returns |
|---|---|---|
regex_match | regex_match:"\d+" | First match (string), or empty |
regex_match (group) | regex_match:"(\d+)":1 | Capture group N (string) |
regex_match_all | regex_match_all:"\d+" | Array of all matches |
regex_replace | regex_replace:"\s+":"_" | String with replacements applied |
regex_test | regex_test:"^https?://" | Boolean |
String filters
trim— strip leading/trailing whitespaceupper/lower— case conversionreplace:"find":"replace"— literal find-and-replace (not regex; useregex_replacefor patterns)slice:start:end— substring or sub-array;endis optionalsplit:"delim"— string → arraylength— string length / array length / object key count
Fallback & serialization
default:"fallback"— use fallback when input is empty/null/undefinedjson— serialize object or array as a JSON string
Common recipes
// Extract phone number from a message
{{ message | regex_match:"\d{3}-\d{4}" }}
// Strip "Re: " from email subjects
{{ subject | replace:"Re: ":"" }}
// Normalize email for matching
{{ email | trim | lower }}
// Pull order ID with capture group
{{ message | regex_match:"order #(\d+)":1 }}
// Truthy check with default
{{ status || "unknown" | upper }}
// First N items from an array (returns real array)
{{ $json.results | slice:0:10 }}Gotchas
- Regex backslashes — write
\dinside double quotes (not\\d). Filter args strip outer quotes and pass the contents directly tonew RegExp(). - Bad regex doesn't crash — an invalid pattern returns empty/false rather than throwing. Your workflow won't fail on a typo.
- Catastrophic backtracking — a pathologically bad regex (like
(a+)+on a long string) can pin the worker. Prefer anchored patterns and avoid nested quantifiers. - Literal
}}in args — ends the expression early. If you genuinely need}}inside a string argument, use single-quoted strings:regex_match:'...'. - Unknown filter names pass through — a typo like
uperinstead ofupperwon't error; the value just isn't transformed. Check the spelling if a filter seems to do nothing.
Available in every text field that supports {{variables}} — HTTP nodes, AI Prompt, Email, Database queries, Webhook responses, and more. No Code node required.