How to Pretty Print JSON in Chrome Developer Console

Make your object readable in console.
Zach Zach (248)
2 minutes

This short guide will show you how to pretty print a JSON object in the Chrome Developer Tools console.

Posted in these interests:
h/javascript27 guides
h/code69 guides
h/webdev60 guides

Wrap your object in JSON.stringify and log it to the console:

const currentlyDrinking = {
    beer: 'Yeungling',
    container: 'bottle',
    empty: true


This will result in the following minified object:


Not exactly pretty yet, so we'll need to format it. This is especially important for larger objects.

To format our object, we'll need to specify the number of spaces we'd like:

const currentlyDrinking = {
    beer: 'Yeungling',
    container: 'bottle',
    empty: true

console.log(JSON.stringify(currentlyDrinking, undefined, 4)); // use 4-space tabs to format and indent the code

This results in:

    "beer": "Yeungling",
    "container": "bottle",
    "empty": true

Much better!

For more Chrome Developer console object pretty-printing options, check out the JSON.stringify() MDN docs.

Eat 'em, freeze 'em, enjoy 'em all week long!
Tayler Tayler (75)
35 minutes

Nothing says good morning quite like a breakfast sandwich. From the doughiness of the muffin to the eggs' fluffiness to the cheese's gooeyness, breakfast sandwiches are a great start to your morning.