---
schema_version: "1"
id: 68da10c84b7ad0ef9184b78b1b3f71cbfd41eef0556bedee3b75a166058cdf5f
title: JSENCODE
collection: admin
version: current
locale: en-us
portal_url: https://docs.salesforce.com/admin/current/en-us/platform/264-0-0/customize_functions_jsencode.md
canonical_url: https://help.salesforce.com/s/articleView?id=platform.customize_functions_jsencode.htm&release=264.0.0&type=5
source_site: help.salesforce.com
content_type: documentation
content_hash: 47199536e70397053890dc2a4e242b14788c69d220baa703c788e33248d4a80a
description: 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 (').
products:
  - Salesforce Platform
  - Security
release: "264"
---
# 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](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-platform-extend_click-264-0-0-production-enus/5f7d9219-b7b1-4552-8891-f1aba9b289fc/images/icon_example.png)

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`