Skip to main content

encodeHtml

Encodes HTML tags in a string so they are rendered verbatim, not interpreted as HTML.

Generally, Studio treats HTML entered in the script editor as plain text; however, you can explicitly instruct it to do this by applying encodeHtml to the relevant string.

This is the sibling function to decodeHtml and reverse its effects. It's also useful when your text describes HTML or character sequences that you don't want the browser to treat as HTML tags.

Parameters

  • STRING (string)

    The input string.

Examples

ATL in Script

Preview Result

Result in API Output

<b>result</b>

<b>result</b>

&lt;b&gt;result&lt;/b&gt;

[[encodeHtml('<b>result</b>')]]

<b>result</b>

&lt;b&gt;result&lt;/b&gt;

[[encodeHtml(decodeHtml('<b>result</b>'))]]

<b>result</b>

&lt;b&gt;result&lt;/b&gt;

The Preview Result column shows the output in Studio's Preview Mode.

The Result in API Output column shows the result when the API output format is HTML (the default). For more about the output format, see contentOutputFormat in Using a Studio app's API > Request body options.