---
title: urlencode
summary: null
url: https://www.fastly.com/documentation/reference/vcl/functions/strings/urlencode
---

```
STRING urlencode(STRING input)
```

**Available in:** all subroutines

Encodes a string for use in a URL. This is also known as 
[percent-encoding](https://en.wikipedia.org/wiki/Percent-encoding). 
For example, `urlencode("hello world");` will return `"hello%20world"`.

This function is not prefixed with the `std.` namespace.

## Example

```vcl
set req.url = req.url "?cookie=" urlencode(req.http.Cookie);
```
