Articles in this section

sanitize helper

The sanitize helper removes all HTML markup tags from a string and returns the plain text content. Use it to clean field values that may contain markup from CMS fields, web forms, or API responses before storing or transmitting them.

Syntax

{{sanitize string}}

string -- The string to sanitize. Required.

Examples

Strip markup from a field value

{{sanitize record.raw}}

Input:

{ "record": { "raw": "<span>Hello <strong>World</strong></span>" } }

Output: Hello World

All tags are removed. The text content inside the tags is preserved.

Usage notes

  • Only markup tags are removed. Text content inside tags is preserved.
  • No spaces or line breaks are added when block-level elements (e.g. <div>, <li>, <td>, <br>) are removed.
  • Self-closing elements such as <img> are removed entirely -- surrounding text is retained.
  • If HTML entities such as &amp; or &lt; remain in the output after sanitizing, use the htmlDecode helper to convert them to readable characters.