---
title: "url_encode function in Strata | Oplema"
description: "Percent-encode text so it's safe to use in a URL, such as a space to %20. Write it as url_encode(string) in a Strata Formula or Filter."
url: "https://oplema.com/docs/strata/functions/url-encode"
updated: "2026-11-04"
---

# url\_encode

Make text safe for a URL by replacing spaces and special characters with percent codes.

## Try an expression

In [Formula](https://oplema.com/docs/strata/prep/formula), enter the expression and set Output type to **VARCHAR**.

### Expression

```
url_encode('this string has/ special+ characters>')
```

### Result

```
'this%20string%20has%2F%20special%2B%20characters%3E'
```

To use your own data, replace the example values with column names. Keep format strings and other options as written.

Try it live in Formula

Result
| id | result |
| --- | --- |
| 1 | this%20string%20has%2F%20special%2B%20characters%3E |

## Arguments and types

```
url_encode(string)
```

**string**

Text

Supported signatures (1)

```
url_encode(string: VARCHAR) → VARCHAR
```

The result type can depend on the input types. See DuckDB for the full argument rules.

## Things to know

If the first argument is missing, the result is NULL.

## Related functions

[url\_decode

Turn percent codes in a URL back into the original characters.

](https://oplema.com/docs/strata/functions/url-decode)[format\_bytes

Convert a byte count to a readable size using units based on powers of 2, such as KiB, MiB and GiB. Also available as pg\_size\_pretty.

](https://oplema.com/docs/strata/functions/format-bytes)[array\_extract

Get one item from a list or one character from text by position, where 1 is the first. For a struct, choose a field by name, or by position in an unnamed struct.

](https://oplema.com/docs/strata/functions/array-extract)[array\_slice

Extract a section of a list or text by start and end positions, where 1 is the first position. Negative positions count from the end.

](https://oplema.com/docs/strata/functions/array-slice)

[Browse text](https://oplema.com/docs/strata/functions#text) [DuckDB documentation](https://duckdb.org/docs/current/sql/functions/text.html#url_encodestring)

Function metadata from DuckDB, used under the [MIT license](https://github.com/duckdb/duckdb/blob/v1.5.4/LICENSE).
