Sunday, April 19, 2026
Craft CMS

Twig Filter Reference

Browse all Craft CMS Twig filters, functions, and tags with examples.

Craft CMS Twig Templating — A Complete Guide

Craft CMS uses Twig as its templating engine, extending the standard Twig library with a rich set of CMS-specific filters, functions, and global variables. Every Craft template file is a .twig file stored in your project's templates/ directory, and Craft resolves which template to render based on section routing rules, entry types, and URL patterns.

Twig filters transform values using the pipe syntax — {{ value | filterName }}. Standard Twig filters like upper, date, and escape work exactly as documented in the Twig manual. Craft adds additional filters such as markdown, currency, group, multisort, and parseRefs that address common CMS content manipulation tasks.

Craft CMS Twig Functions

Twig functions are called with parentheses — {{ functionName(args) }}. Craft's function library includes helpers for generating URLs (siteUrl, cpUrl, actionUrl), rendering SVGs (svg), working with HTML tags (tag, input), and interacting with the application layer (craft.app, getenv, parseEnv).

Understanding the distinction between filters and functions helps when reading or writing templates. Filters always operate on a left-hand value and are chained with |. Functions stand alone and can accept multiple arguments. Both can be nested — for example, {{ entry.body | markdown | purify }} renders Markdown content and then sanitizes the resulting HTML.

Craft 4 vs Craft 5 Differences

Craft 5 introduced several new filters and deprecated others from Craft 4. The money field and its formatting filters were introduced in Craft 5. The timestamp filter replaces some manual date formatting patterns. When upgrading from Craft 4, review deprecated usage with Craft's built-in deprecation logger at /admin/utilities/deprecation-errors. This reference marks entries with a version badge indicating compatibility.