- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Unescape HTML entities in JavaScript?
To unescape HTML entities in JavaScript, use the unescaped() function. Let’s say you want to encode special character with the unescape() function −
document.write(unescape("Demo%20Text%20"));
In this article, we will see two examples −
- Unescape Entities
- Decode the Encoded String
Unescape Entities
Example
Lo unescape, we will use the unescaped() method in JavaScript. Let us see an example −
<!DOCTYPE html> <html> <body> <h2>Demo Heading</h2> <script> document.write(unescape("Demo%20Text%20")); </script> </body> </html>
Output

Decode the Encoded String
Use escape() for encoding and unescape() for decoding. Here, we will set a sample string under the escape() method to encode −
var myStr = escape("Demo Text!!!"); document.write("Encoded String = " + myStr);
After that, we will use the unescape() to decode the encoded string −
document.write("Decoded = " + unescape(myStr))
Example
Let us now see the example −
<!DOCTYPE html> <html> <body> <h2>Demo Heading</h2> <script> var myStr = escape("Demo Text!!!"); document.write("Encoded String = " + myStr); document.write("<br>"); document.write("<hr>"); document.write("Decoded = " + unescape(myStr)) </script> </body> </html>
Output

- Related Articles
- HTML Entities
- JavaScript unescape() with example
- What is difference between unescape() and escape() functions in JavaScript?
- What are Character Entities in HTML5
- Types of DBMS Entities and their examples
- JavaScript JSON HTML
- How to include JavaScript in HTML Documents?
- How to embed JavaScript in HTML file?
- Convert HTML table to array in JavaScript?
- How to access HTML elements in JavaScript?
- How to Handle JavaScript Events in HTML?
- How to return HTML or build HTML using JavaScript?
- Difference between JavaScript and HTML
- Detecting HTML click-to-call support in JavaScript
- What is nodeName property in JavaScript HTML DOM?

Advertisements