How to Remove JSON Escape Characters in Javascript?

Nov 07, 2022 . Admin



Hello friends,

This simple article demonstrates how to remove JSON escape characters in javascript. I’m going to show you about removing escape characters JSON with an example. if you want to see an example of removing escape characters in javascript then you are in the right place. This article will give you a simple example of removing escape characters in javascript. Follow the below tutorial of javascript to remove escape characters JSON with an example.

To remove the escape characters, you can use You can use JSON.stringify() and replace() to replace escape characters. We have seen how to solve the Remove Escape Characters From JSON with an example.

So, let's see bellow solution:

Example:
index.html
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>How to Remove JSON Escape Characters in Javascript? - Mywebtuts.com </title>
</head>
<body>
<script type="text/javascript">
    
    //create json data
    var jsonData = {"\\id\\":"\\23232\\","\\pass\\":"\\1434\\"};

    //convert json data stringify
    var stringifyData = JSON.stringify(jsonData);

    //get new string json data stringify
    newStr = stringifyData.replace(/\\/g, '');

    //print remove json escape characters
    console.log(newStr);

</script>
</body>
</html>
Check The Console For Output:
{"id":"23232","pass":"1434"}

I hope it will help you...

#Javascript