Loading
Salesforce Enforces New Security Requirements in Summer 2026Read More
Extend Salesforce with Clicks, Not Code
JSINHTMLENCODE

JSINHTMLENCODE

Encodes text and merge field values for use in JavaScript inside HTML tags by replacing characters that are reserved in HTML with HTML entity equivalents and inserting escape characters before unsafe JavaScript characters.

JSINHTMLENCODE(someValue) is a convenience function that is equivalent to JSENCODE(HTMLENCODE((someValue)). That is, JSINHTMLENCODE first encodes someValue with HTMLENCODE, and then encodes the result with JSENCODE.

Use

{!JSINHTMLENCODE(text)} and replace text with the merge field or text string that contains the unsafe JavaScript characters.

Tips

  • This function is only available in custom buttons and links, and in Visualforce.
Merge Field Example
Merge Field Example

If the merge field foo__c contains <B>Enter the user's name<b>, {!JSINHTMLENCODE(foo__c)} results in: &lt;B&gt;Enter the user&#39;s name&lt;/b&gt;

 
Loading
Salesforce Help | Article