---
title: url_decode
description: "url\\_decode function in PySpark: Decodes a URL-encoded string in 'application/x-www-form-urlencoded' format to its original format."
canonical_url: https://docs.databricks.com/aws/en/pyspark/reference/functions/url_decode
---

# url\_decode

Decodes a URL-encoded string in 'application/x-www-form-urlencoded' format to its original format.

## Syntax

```python
from pyspark.sql import functions as sf

sf.url_decode(str)
```

## Parameters

| Parameter | Type                        | Description                                                  |
| --------- | --------------------------- | ------------------------------------------------------------ |
| `str`     | `pyspark.sql.Column` or str | A column of strings, each representing a URL-encoded string. |

## Returns

`pyspark.sql.Column`: A new column of strings, each representing the decoded string.

## Examples

**Example 1**: Decoding a URL-encoded string

```python
from pyspark.sql import functions as sf
df = spark.createDataFrame([("https%3A%2F%2Fspark.apache.org",)], ["url"])
df.select(sf.url_decode(df.url)).show(truncate=False)
```

```Output
+------------------------+
|url_decode(url)         |
+------------------------+
|https://spark.apache.org|
+------------------------+
```

**Example 2**: Decoding a URL-encoded string with spaces

```python
from pyspark.sql import functions as sf
df = spark.createDataFrame([("Hello%20World%21",)], ["url"])
df.select(sf.url_decode(df.url)).show()
```

```Output
+---------------+
|url_decode(url)|
+---------------+
|   Hello World!|
+---------------+
```

**Example 3**: Decoding a URL-encoded string with special characters

```python
from pyspark.sql import functions as sf
df = spark.createDataFrame([("A%2BB%3D%3D",)], ["url"])
df.select(sf.url_decode(df.url)).show()
```

```Output
+---------------+
|url_decode(url)|
+---------------+
|          A+B==|
+---------------+
```

**Example 4**: Decoding a URL-encoded string with non-ASCII characters

```python
from pyspark.sql import functions as sf
df = spark.createDataFrame([("%E4%BD%A0%E5%A5%BD",)], ["url"])
df.select(sf.url_decode(df.url)).show()
```

```Output
+---------------+
|url_decode(url)|
+---------------+
|           你好|
+---------------+
```

**Example 5**: Decoding a URL-encoded string with hexadecimal values

```python
from pyspark.sql import functions as sf
df = spark.createDataFrame([("%7E%21%40%23%24%25%5E%26%2A%28%29%5F%2B",)], ["url"])
df.select(sf.url_decode(df.url)).show()
```

```Output
+---------------+
|url_decode(url)|
+---------------+
|  ~!@#$%^&*()_+|
+---------------+
```
