Outputing human friendly JSON string with JSON.stringify

method 1:

JSON.stringify(obj, null, '\t');

This "pretty-prints" your JSON string, using a tab for indentation.

method 2:

If you prefer to use spaces instead of tabs, you could also use a number for the number of spaces you'd like :

JSON.stringify(obj, null, 2);

Reference

Comments

  1. Markdown is allowed. HTML tags allowed: <strong>, <em>, <blockquote>, <code>, <pre>, <a>.