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": "http://unsharptech.com",
  "hash": "",
  "search": "",
  "pathname": "/category/web-dev/",
  "port": "",
  "hostname": "unsharptech.com",
  "host": "unsharptech.com",
  "protocol": "http:",
  "href": "http://unsharptech.com/category/web-dev/"
}

JSON.stringify documentation