Whatever message this page gives is out now! Go check it out!

URLEncodedFormat

Last update:
May 18, 2026
Note: Adobe recommends that you use the EncodeForURL function, not the URLEncodedFormat function, to escape special characters in a string for use in a URL in all new applications.

Description

Generates a URL-encoded string. For example, it replaces spaces with %20, and non-alphanumeric characters with equivalent hexadecimal escape sequences. Passes arbitrary strings within a URL (ColdFusion automatically decodes URL parameters that are passed to a page).

Returns

A copy of a string, URL-encoded.

Category

Function syntax

URLEncodedFormat(string [, charset ])
See also
URLDecodeTags and functions for globalizing applications in the Developing ColdFusion Applications

History

ColdFusion MX 6.1: Changed the default encoding to be the response character encoding.
ColdFusion MX: Added the charset parameter.

Parameters

Parameter
Description
string
A string or a variable that contains one
charset
The character encoding in which the string is encoded.
Optional.The following list includes commonly used values:

Usage

URL encoding formats some characters with a percent sign and the two-character hexadecimal representation of the character. For example, a character whose code is 129 is encoded as %81. A space is replaced with %20. Query strings in HTTP are always URL-encoded.

Example

<h3>URLEncodedFormat Example</h3> 
<cfif IsDefined("url.myExample")> 
<p>The url variable url.myExample was passed from the previous link ... 
its value is: 
<br><b>"<cfoutput>#url.myExample#</cfoutput>"</b> 
</cfif> 
<p>This function returns a URL encoded string. 
<cfset s = "My url-encoded string has special characters & other stuff"> 
<p> <A HREF = "urlencodedformat.cfm?myExample=<cfoutput>#URLEncodedFormat(s)# 
</cfoutput>">Click me</A>

Share this page

Was this page helpful?
We're glad. Tell us how this page helped.
We're sorry. Can you tell us what didn't work for you?
Thank you for your feedback. Your response will help improve this page.

On this page