JSON Stringify
<!DOCTYPE html> <html> <body> <h2>Result</h2> <p id="demo"></p> <script> const user = { name: "Riya", age: 29, active: true }; const text = JSON.stringify(user); console.log(text); // '{"name":"Riya","age":29,"active":true}' console.log(typeof text); // "string" </script> </body> </html>