Handlebars encodeURIComponent
Handlebars encodeURIComponent: URL-encodes the part of a string that comes after the address, such as a query string.
Next
Runtime verified
Test scripts included
URL-encodes the part of a string that comes after the address, such as a query string. For a whole string, use encodeURI.
Syntax
{{encodeURIComponent text}}
Returns string.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
text |
string | Yes | The text to encode. |
Example
Tested in a Marketing Cloud Next email on 2026-11-22:
{{encodeURIComponent "a b/c"}}rendersa%20b%2Fc.
Show Next test script
Marketing Cloud Next
Works as documented
{{encodeURIComponent "a b/c"}} renders a%20b%2Fc: both the space and the slash are encoded. Tested 2026-11-22 by rendering in a Marketing Cloud Next email.
See also
- AMPscript
URLEncode— does a similar job in AMPscript, with a different call shape - Official reference