---
schema_version: "1"
id: 07801d61bbb76f7be9d650abe61bad450b42ef11931651444d2782b18c520d3a
title: URLENCODE
collection: admin
version: current
locale: en-us
portal_url: https://docs.salesforce.com/admin/current/en-us/platform/264-0-0/customize_functions_urlencode.md
canonical_url: https://help.salesforce.com/s/articleView?id=platform.customize_functions_urlencode.htm&release=264.0.0&type=5
source_site: help.salesforce.com
content_type: documentation
content_hash: 771de0a28982807642b1ae83ac7c90d9ee3e9d5c263cd45cb1a52892f204c3c0
description: "Encodes text and merge field values for use in URLs by replacing characters that are illegal in URLs, such as blank spaces, with the code that represent those characters as defined in RFC 3986, Uniform Resource Identifier (URI): Generic Syntax."
products:
  - Salesforce Platform
  - Security
release: "264"
---
# URLENCODE

Encodes text and merge field values for use in URLs by replacing characters that are illegal in URLs, such as blank spaces, with the code that represent those characters as defined in RFC 3986, Uniform Resource Identifier (URI): Generic Syntax.

For example, blank spaces are replaced with `%20`, and exclamation points are replaced with `%21`.

## Use

`{!URLENCODE(text)}` and replace text with the merge field or text string that you want to encode.

## Tips

- This function is only available in custom buttons and links, and in Visualforce.
- Custom buttons and links with URL content sources have separate encoding settings. If you use the URLENCODE function to encode a custom button or link that has an encoding setting specified, Salesforce first encodes the URL according to the custom button or link setting, then encodes the result. For example, if the URL in a custom link contains a space and its encoding setting is UTF8, Salesforce first encodes the space to a plus sign (+), then the URLENCODE function converts the plus sign to its character code, `%2B`.
- When you include the standard Account field on opportunities (`Opportunity.Account`) in the URLENCODE function, the value of the field is the account ID, not the account name. To encode the account name, create a custom cross-object formula field on opportunities that spans to the account name, and use that field in the URLENCODE function instead of `Opportunity.Account`. For example, if the cross-object formula is AccountNameFormula\_\_c, use the following:
    
    ```
    http://www.google.com/search?q={!URLENCODE
    (Opportunity.AccountNameFormula__c)}
    ```

![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>Mark's page<b>`, `{!URLENCODE(foo_c)}` results in: `%3CB%3EMark%27s%20page%3C%2Fb%3E`