Show Output
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>Convert JavaScript Object to JSON string</title> </head> <body> <script> // Sample JS object let obj = {"name": "Peter", "age": 22, "country": "United States"}; // Converting JS object to JSON string let json = JSON.stringify(obj); document.write(json); </script> </body> </html>