Web function

ENCODEURL function

Converts text into URL-encoded form, replacing spaces and special characters with %-codes so the text can be used safely inside a web address.

Available in Excel 2013 and later for Windows, including Microsoft 365; may be missing in Excel for Mac and Excel for the web

Excel 2013 and laterWorks in Google Sheets

Syntax

ENCODEURL(text)
ArgumentWhat it means
textRequiredThe text to encode, such as a search term, a file name or a query-string value.

Returns: The encoded text, e.g. red%20office%20chair for red office chair.

How ENCODEURL works

Web addresses may only contain a limited set of characters. Spaces, ampersands, slashes, accented letters and many symbols have special meanings or are not allowed, so they must be written as a percent sign followed by a hexadecimal code - a space becomes %20, an ampersand %26. ENCODEURL does this conversion for you, which matters whenever you build a link or an API request from cell values with HYPERLINK or WEBSERVICE.

Letters, digits and the characters -, _, . and ~ are left unchanged; everything else is encoded, including /, : and ?. Non-English characters are converted to their UTF-8 bytes, so é becomes %C3%A9. Because even slashes are encoded, apply ENCODEURL to the values that go into an address (the search term, the file name), not to the whole URL.

Examples

1Encode a search term

B2fx="https://www.example.com/search?q=" & ENCODEURL(A2)
AB
1Search termLink
2red office chairhttps://www.example.com/search?q=red%20office%20chair

Result: https://www.example.com/search?q=red%20office%20chair

Only the search term is encoded; the spaces become %20, giving a valid address you can wrap in HYPERLINK.

2Ampersands and other symbols

B2fx=ENCODEURL(A2)
AB
1Department
2Sales & Marketing Q1Sales%20%26%20Marketing%20Q1

Result: Sales%20%26%20Marketing%20Q1

An unencoded & would split a query string in two. ENCODEURL turns it into %26 and the spaces into %20.

3Accented characters

B2fx=ENCODEURL(A2)
AB
1Customer
2Café Müller, KölnCaf%C3%A9%20M%C3%BCller%2C%20K%C3%B6ln

Result: Caf%C3%A9%20M%C3%BCller%2C%20K%C3%B6ln

Each accented letter becomes two UTF-8 bytes (é is %C3%A9), and the comma becomes %2C.

⬇Practice workbookExamples with live formulas + practice sheets · .xlsx · 15 KB

Common errors and how to fix them

ErrorWhy it happensFix
#VALUE!The text is longer than Excel can handle in a URL context or is an error value.Check the source cell.
Broken linkThe whole URL was encoded, so https:// became https%3A%2F%2F.Encode only the parts that go after = in the query string.

Tips

  • Combine with HYPERLINK to create clickable search links for a list of product names.
  • Spaces are encoded as %20, not +; most web servers accept both in query strings.

Google Sheets

ENCODEURL also exists in Google Sheets and works the same way for everyday use, so the examples above work there too.

ENCODEURL in other languages

In a non-English version of Excel the function has a local name. Excel translates formulas automatically when a file is opened in another language.

LanguageFunction name
DanishKODNINGSURL
DutchURL.CODEREN
FinnishURLKOODAUS
GermanURLCODIEREN
HungarianURL.KÓDOL
ItalianCODIFICA.URL
Norwegian (Bokmål)URL.KODE
Portuguese (Brazil)CODIFURL
Portuguese (Portugal)CODIFICAÇÃOURL
RussianКОДИР.URL
SpanishURLCODIF
SwedishKODAWEBBADRESS
TurkishURLKODLA