escape

Escape HTML special characters such as &, <, >, and " into safe HTML entities.

Syntax

{{ html_string | escape }}

Example

{% assign tag = "<div>Featured</div>" %}{{ tag | escape }}

Output

&amp;lt;div&amp;gt;Featured&amp;lt;/div&amp;gt;

The escape filter converts HTML reserved characters (&, <, >, and ") into their corresponding entity representations (&amp;, &lt;, &gt;, &quot;), preventing browsers from rendering them as active markup.

In programmatic keyword generation, escape secures pages against accidental markup injection from third-party vendor CSV feeds. For example: {{ row.customer_quote | escape }}. This prevents broken layout hierarchies or unintended tag closures if an attribute contains angle brackets or raw quotes, ensuring valid HTML output.

Try this syntax in the editor.