Global / Window

decodeURI

Decodes a Uniform Resource Identifier previously created by encodeURI or by a similar routine

Syntax

JavaScript
decodeURI(encodedURI)

Parameters

ParameterTypeDescription
encodedURIstringA complete, encoded URI

Return Value

A new string representing the unencoded version of the encoded URI

Examples

Basic Usage
const encoded = 'https://example.com/path%20with%20spaces';
console.log(decodeURI(encoded));
// 'https://example.com/path with spaces'
Practical Example
const uri = 'https://example.com/%E4%B8%AD%E6%96%87';
console.log(decodeURI(uri)); // 'https://example.com/中文'
Advanced Usage
try {
  decodeURI('%E0%A4%A'); // malformed
} catch (err) {
  console.log(err instanceof URIError); // true
}

Understanding decodeURI

The decodeURI method in JavaScript decodes a Uniform Resource Identifier previously created by encodeURI or by a similar routine. It belongs to the window object and is one of the most widely used methods for working with window values in modern JavaScript and TypeScript applications.

The method signature is decodeURI(encodedURI). It accepts 1 parameter: encodedURI. When called, it returns a new string representing the unencoded version of the encoded uri. Understanding when and how to use decodeURI() helps you write more expressive, readable code.

Common use cases for decodeURI include data transformation, input validation, API response processing, and building reusable utility functions. It works well alongside related methods like window-encodeuri, window-decodeuricomponent, window-encodeuricomponent, enabling you to chain operations together for complex data manipulation pipelines.

Browser support for decodeURI is excellent across all modern browsers including Chrome, Firefox, Safari, and Edge. It is also fully supported in Node.js and Deno. For older environments, transpilation with Babel or a polyfill may be needed.

Browser Compatibility

Supported in all modern browsers (Chrome, Firefox, Safari, Edge) and Node.js. Part of the ECMAScript standard.

Related Methods

More Global / Window Methods

Other methods in the Global / Window object

Related Tools

More Global / Window Methods

Explore JavaScript Methods

Browse our complete reference of 410 JavaScript methods with syntax, examples, and explanations.