JavaScript unescape() with example

JavascriptWeb DevelopmentObject Oriented Programming

The JavaScript unescape() function is used to decode an encoded string. It is deprecated in JavaScript version 1.5.

Following is the code for the unescape() function −


 Live Demo

<!DOCTYPE html>
<html lang="en">
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
   body {
      font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
   .result {
      font-size: 18px;
      font-weight: 500;
      color: red;
   .result {
      color: blueviolet;
<h1>JavaScript unescape() property</h1>
<div class="sample"></div>
<div class="result"></div>
<button class="Btn">CLICK HERE</button>
CLICK the above button to decode the above url
   let sampleEle = document.querySelector(".sample");
   let resultEle = document.querySelector(".result");
   let url = "Hello World?image=8sf.jpg&size=400px";
   sampleEle.innerHTML = "Encoded url = " + escape(url) + "<br>";
   document.querySelector(".Btn").addEventListener("click", () => {
      resultEle.innerHTML = "Decoded url = " + unescape(url);


On clicking the ‘CLICK HERE’ button −

Updated on 12-May-2020 06:11:52