How to display the content of a JavaScript object in a string format?

The simplest way to convert an object to a readable string format is to use JSON.stringify(). This will convert the object into a JSON string, making it easy to display.

var obj = { name: 'John', age: 30, city: 'New York' };
alert(JSON.stringify(obj));

This method is perfect for displaying the entire object as a string in a readable format. If the object has nested objects or arrays, JSON.stringify() will handle them as well.