---
hide_title: false
hide_table_of_contents: false
pagination_next: null
pagination_prev: null
---
# decodeURI

The **`decodeURI()`** function decodes a Uniform Resource Identifier (URI) previously created by [`encodeURI()`](../globals/encodeURI.mdx) or a similar routine.

## Syntax

```js
decodeURI(encodedURI)
```

### Parameters

- `encodedURI`
  - : A complete, encoded Uniform Resource Identifier.

### Return value

A new string representing the unencoded version of the given encoded Uniform Resource Identifier (URI).

### Exceptions

- [`URIError`](../globals/URIError/URIError.mdx)
  - : Thrown if `encodedURI` contains a `%` not followed by two hexadecimal digits, or if the escape sequence does not encode a valid UTF-8 character.

## Description

`decodeURI()` is a function property of the global object.

The `decodeURI()` function decodes the URI by treating each escape sequence in the form `%XX` as one UTF-8 code unit (one byte). In UTF-8, the number of leading 1 bits in the first byte, which may be 0 (for 1-byte ASCII characters), 2, 3, or 4, indicates the number of bytes in the character. So by reading the first escape sequence, `decodeURI()` can determine how many more escape sequences to consume. If `decodeURI()` fails to find the expected number of sequences, or if the escape sequences don't encode a valid UTF-8 character, a [`URIError`](../globals/URIError/URIError.mdx) is thrown.

`decodeURI()` decodes all escape sequences, but if the escape sequence encodes one of the following characters, the escape sequence is preserved in the output string (because they are part of the URI syntax):

```
; / ? : @ & = + $ , #
```
