Pretty print to console in Node.js

JSON.stringify is pretty cool, in fact you can use it to print javascript data structures in a more readable format.

Of course modern browser javascript consoles already format nested data for you, but this is really helpful when using console.log() in Node.js

console.log(JSON.stringify(window.location, null, 2));

// prints...
  "ancestorOrigins": {
    "length": 0
  "origin": "",
  "hash": "",
  "search": "",
  "pathname": "/category/web-dev/",
  "port": "",
  "hostname": "",
  "host": "",
  "protocol": "http:",
  "href": ""

JSON.stringify documentation