Filters are used to transform a variable before outputting it. You can pipe a variable through one or more filters using the | character.

Learn more about filters in Dust.js.

Built-in Filters

Dust.js ships with the following built-in filters.

  • h – HTML-encode a string
  • s – turn off automatic HTML encoding
  • j – JavaScript-encode a string
  • u – encodeURI
  • uc – encodeURIComponent
  • js – JSON.stringify
  • jp – JSON.parse



Custom Filters

Postleaf provides a handful of additional filters that are useful for converting variables to and from HTML.

  • htmlToText – convert an HTML string to plain text
  • markdownToHtml – convert a markdown string to HTML
  • markdownToText – convert a markdown string to text




Filters can be applied to variables, but not helpers. This is perfectly valid:


But this is not:

{@date format="YYYY"|u/} - incorrect!