[ Web Proxy ]
URL:
Viewing: https://developer.mozilla.org/ru/docs/Web/JavaScript/Reference/Global_Objects/decodeURI [Back]  [Original]

decodeURI() - JavaScript | MDN

This page was translated from English by the community. Learn more and join the MDN Web Docs community.

View in English Always switch to English

decodeURI()

Baseline Widely available

This feature is well established and works across many devices and browser versions. Its been available across browsers since 2015 ..

decodeURI() (URI), encodeURI .

In this article

const uri = "https://mozilla.org/?x=";
const encoded = encodeURI(uri);
console.log(encoded);
// Expected output: "https://mozilla.org/?x=%D1%88%D0%B5%D0%BB%D0%BB%D1%8B"

try {
  console.log(decodeURI(encoded));
  // Expected output: "https://mozilla.org/?x="
} catch (e) {
  // Catches a malformed URI
  console.error(e);
}

decodeURI(encodedURI)

encodedURI

.

, .

Exceptions

Throws an URIError ("malformed URI sequence") exception when encodedURI contains invalid character sequences.

URI . , encodeURI. "#" .

URL

js
decodeURI(
  "https://developer.mozilla.org/ru/docs/JavaScript_%D1%88%D0%B5%D0%BB%D0%BB%D1%8B",
);
// "https://developer.mozilla.org/ru/docs/JavaScript_"

Catching errors

try {
  var a = decodeURI('%E0%A4%A');
} catch(e) {
  console.error(e);
}

// URIError: malformed URI sequence

Specification
ECMAScript 2027 LanguageSpecification
# sec-decodeuri-encodeduri


Web Proxy Viewer  |  New URL  |  Original Page