# URL\_ENCODE

**The function URL\_ENCODE escapes characters that have a special meaning in URLs.**

This function takes a primitive ([String](../../variable-data-types/the-text-variable-data-type), [Number](../../variable-data-types/the-number-variable-data-type), or [Boolean](../../variable-data-types/the-boolean-variable-data-type)), and returns a string representation of the input with any special URL characters (such as **'/'**, **'='**, etc...) replaced with the character's [Percent Encoding](https://en.wikipedia.org/wiki/Percent-encoding). This function is useful when you need to display a URL to the user that contains data that the user entered.

#### Declaration

```javascript
URL_ENCODE(primitive) -> encoded_string
```

#### Parameters

**primitive** (type: _string | number | boolean_) The primitive to encode.

#### Return Values

**encoded\_string** (type: _string_) The URL encoded string

#### Examples

For this example assume that a user has entered some text that is stored in a variable named **search\_query**.

```javascript
search_query = "date/time"
```

We would like to create a hyperlink to a google search for the search query the user provided. This is done by adding the search query to the url. Note, however, that the user's query contains a slash character, which has a special meaning in a URL. When creating the hyper link we must escape any such characters. Note how the slash character is converted into the characters **"%2F"**. Each special character will have its own code.

```javascript
"https://www.google.com/search?q={{URL_ENCODE(search_query)}}" ->  
"https://www.google.com/search?q=date%2Ftime"
```

#### Discussion

The [URL\_DECODE](url_decode) function will perform the opposite operation, in other words, it will convert any URL percent encodings into the matching character.
