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 array

Note: 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

FilterExampleReturns
regex_matchregex_match:"\d+"First match (string), or empty
regex_match (group)regex_match:"(\d+)":1Capture group N (string)
regex_match_allregex_match_all:"\d+"Array of all matches
regex_replaceregex_replace:"\s+":"_"String with replacements applied
regex_testregex_test:"^https?://"Boolean

String filters

  • trim — strip leading/trailing whitespace
  • upper / lower — case conversion
  • replace:"find":"replace" — literal find-and-replace (not regex; use regex_replace for patterns)
  • slice:start:end — substring or sub-array; end is optional
  • split:"delim" — string → array
  • length — string length / array length / object key count

Fallback & serialization

  • default:"fallback" — use fallback when input is empty/null/undefined
  • json — 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 \d inside double quotes (not \\d). Filter args strip outer quotes and pass the contents directly to new 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 uper instead of upper won'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.