The ENCODEURL function in Google Sheets is useful if you want to convert a provided string into a URL-encoded format.
Meaning, the ENCODEURL function returns a string with a URL code or a valid format of the provided URL that the Internet can understand.
Table of Contents
The rules for using the ENCODEURL function in Google Sheets are as follows:
- If the provided text is not a URL string, the function would still encode it as a URL string.
Let’s take an example.
Take a look at the table below and see how the provided texts are encoded:
With the help of the ENCODEURL function, we can convert the URLs or texts provided on the left above into a format that the Internet can understand.
This means that in the front-end, what we can see are the texts on the left. In the back-end, the URLs and texts are converted into the values on the right.
Watch out for a more advanced tutorial and examples on how you can use the ENCODEURL function in the coming weeks. Be sure to subscribe to be notified.
Perfect! Let’s begin getting to know more about our ENCODEURL function in Google Sheets.
The Anatomy of the ENCODEURL Function
So the syntax (the way we write) of the ENCODEURL function is as follows:
Let’s dissect this thing and understand what each of these terms means:
- = the equal sign is just how we start any function in Google Sheets. It is how Google Sheets understand that we are asking it to either do computation or use a function.
- ENCODEURL() this is our ENCODEURL function. It returns a URL-encoded string.
- text is the string that requires URL encoding.
A Real Example of Using ENCODEURL Function
Let’s take a look at the examples below to see how the ENCODEURL function is used in Google Sheets.
The ENCODEURL function has only one argument. That’s the text or string to be URL encoded.
Notice how some of the characters in the provided texts in column A were changed into percent-codes.
The ENCODEURL function is intended for a URL string.
What is a URL?
A URL(Uniform Resource Locator) is the address of a webpage or resource on the world wide web (www). These addresses are formed based on a set of rules. One of those rules is about how characters in a URL are being interpreted on the internet.
Some characters can be used without issues. That includes numbers (0-9) and letters (A-Z, a-Z), as well as some special characters (-, ., _).
Some characters are considered unsafe. The ENCONDEURL function helps converts these unsafe characters into percent-codes, or a format that’s aligned on the set of rules.
In this way, we can use any character we want.
Please see the table below for some of the common unsafe and reserved characters being used and their encoded format:
If the provided URL or string in the function contains some of these unsafe and reserved characters, the ENCODEURL simply converts them into their corresponding encoded characters.
Take a look at the example in the first row:
All letters in the provided text above were retained in the Encoded column. However, the colon(:) and the two forward-slash (/) were translated into %3A and %2F, respectively.
Why is that so?
Well, that’s because colon and forward-slash are two examples of those reserved characters.
Let’s take another example.
While the two provided texts above are not URLs, note that the ENCODEURL function still converts them into URL-encoded strings.
In the string example “Hello World”, only space( ) character is considered unsafe. Hence, it was converted to its corresponding encoded character, which is %20.
In the string example “Sheetaki (Subscribe Now!)”, there were 4 unsafe and reserved characters. These are the space( ), open parenthesis ‘(‘, close parenthesis ‘)’, and the exclamation point(!). They were converted into %20, %28, %29, and %21, respectively.
You may make a copy of the spreadsheet using the link I have attached below.
How to Use ENCODEURL Function in Google Sheets
- Click on any cell to make it the active cell. For this guide, I will be selecting B2, where I want to show the resulting array of information.
- Next, type the equal sign ‘=‘ to begin the function and then follow it with the name of the function, which is our ‘encodeurl‘ (or ‘ENCODEURL‘, not case sensitive like our other functions).
- Type open parenthesis ‘(‘ or simply hit Tab key to let you use that function.
- Now the exciting part! Let’s give our function its only argument, the text. Click on cell A2 or you can type in ‘A2’.
- Finally, hit your Enter or Tab key. Cell B2 will now show you the result or the return value of the ENCODEURL function, which is the URL-encoded string of the text in A2.
- Copy the formula down to the remaining rows.
That’s pretty much it. You can now use the ENCODEURL function in Google Sheets together with the other numerous Google Sheets formulas to create even more powerful formulas that can make your life much easier.