how to pretty pring json in javascxiprt as text code example Example: JSON.stringify pretty var str = JSON.stringify(obj, null, 2); // spacing level = 2