encodeURIComponent(text) Last updated: 30. May 2026

Encodes a URI component by replacing certain characters with escape sequences representing the UTF-8 encoding. Unlike encodeURI, it also encodes characters such as ?, =, & and /, making it suitable for encoding individual components of a URL.

Parameters

Name Type Description
text string

Text to encode

Returns

An encoded string.

Example

Code example (#JS)

#JS is mixed HTML (or other text file) with inline JavaScript with # starting and ending each inline statement.
#write(encodeURIComponent("https://testing.com?quotes=\"\""))#

Output

The #JS code above produces the output shown below:
https%3a%2f%2ftesting.com%3fquotes%3d%22%22