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)| Argument | What it means | |
|---|---|---|
text | Required | The 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
| A | B | |
|---|---|---|
| 1 | Search term | Link |
| 2 | red office chair | https://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
| A | B | |
|---|---|---|
| 1 | Department | |
| 2 | Sales & Marketing Q1 | Sales%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
| A | B | |
|---|---|---|
| 1 | Customer | |
| 2 | Café Müller, Köln | Caf%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.
Common errors and how to fix them
| Error | Why it happens | Fix |
|---|---|---|
#VALUE! | The text is longer than Excel can handle in a URL context or is an error value. | Check the source cell. |
Broken link | The 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.
| Language | Function name |
|---|---|
| Danish | KODNINGSURL |
| Dutch | URL.CODEREN |
| Finnish | URLKOODAUS |
| German | URLCODIEREN |
| Hungarian | URL.KÓDOL |
| Italian | CODIFICA.URL |
| Norwegian (Bokmål) | URL.KODE |
| Portuguese (Brazil) | CODIFURL |
| Portuguese (Portugal) | CODIFICAÇÃOURL |
| Russian | КОДИР.URL |
| Spanish | URLCODIF |
| Swedish | KODAWEBBADRESS |
| Turkish | URLKODLA |