Loading
Salesforce Enforces New Security Requirements in Summer 2026Read More
Extend Salesforce with Clicks, Not Code
Table of Contents
Select Filters

          No results
          No results
          Here are some search tips

          Check the spelling of your keywords.
          Use more general search terms.
          Select fewer filters to broaden your search.

          Search all of Salesforce Help
          JSENCODE

          JSENCODE

          Encodes text and merge field values for use in JavaScript by inserting escape characters, such as a backslash (\), before unsafe JavaScript characters, such as the apostrophe (').

          Use

          {!JSENCODE(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>, {!JSENCODE(foo__c)} results in: \u003CB\u003EEnter the user\'s name\u003C\/b\u003E

           
          Loading
          Salesforce Help | Article