---
title: url_encode function
description: Learn the syntax of the url\_encode function of the SQL language in Databricks SQL and Databricks Runtime.
canonical_url: https://docs.databricks.com/aws/en/sql/language-manual/functions/url_encode
---

# `url_encode` function

**Applies to:** ![check marked yes](https://docs.databricks.com/aws/en/images/icons/check.png) Databricks SQL ![check marked yes](https://docs.databricks.com/aws/en/images/icons/check.png) Databricks Runtime 11.3 LTS and above

Translates a string into [application/x-www-form-urlencoded](https://www.w3.org/TR/html4/interact/forms.html#h-17.13.4.1) format.

## Syntax

```
url_encode(str)
```

## Arguments

* `str`: A STRING expression to encode.

## Returns

A `STRING` compliant with [application/x-www-form-urlencoded (www.w3.org)](https://www.w3.org/TR/html4/interact/forms.html#h-17.13.4.1) format:

## Examples

```sql
> SELECT url_encode('http://spark.apache.org/path?query=1');
 http%3A%2F%2Fspark.apache.org%2Fpath%3Fquery%3D1

> SELECT url_decode('http%3A%2F%2Fspark.apache.org%2Fpath%3Fquery%3D1');
 http://spark.apache.org/path?query=1

> SELECT url_decode('http%3A%2F%2spark.apache.org');
 Error: CANNOT_DECODE_URL

> SELECT parse_url('http://spark.apache.org/path?query=1', 'QUERY', 'query');
 1

> SELECT parse_url(url_decode('http%3A%2F%2Fspark.apache.org%2Fpath%3Fquery%3D1'), 'HOST');
 1
```

## Related functions

* [`parse_url` function](https://docs.databricks.com/aws/en/sql/language-manual/functions/parse_url.md)
* [`url_decode` function](https://docs.databricks.com/aws/en/sql/language-manual/functions/url_decode.md)
