Docly Developers
Function Updated 23 Oct 2026

encodeURIComponent(text)

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.

Encodes as in standard JavaScript: a space becomes %20, hex digits are upper case (%3F), and A–Z a–z 0–9 - _ . ! ~ * ' ( ) are left as they are. Because ' is not encoded, put the value in an attribute with double quotes (href="…"), never single quotes. null and undefined return null.

Earlier versions of Docly encoded like an HTML form (a space became +). decodeURIComponent no longer turns + into a space either; read values that were stored that way with urlDecode(). For form encoding, use urlEncode().

Parameters

textstringrequired

Text to encode

Returns

An encoded string.

Example

Mixed HTML (or any text file) with inline JavaScript between hash signs.
#write(encodeURIComponent("https://testing.com?quotes=\"\""))#