Tuesday, September 17, 2013

Online formatters & pretty printers

A few online resources that I use on a daily basis for formatting / pretty printing:

JSON Viewer:
Simple, straighforward, and FULL SCREEN!  ( I hate JSONLint because its window is so small )
There is also a 'View' mode that displays your JSON as an interactive (collapse/expand) list.
jsonviewer.stack.hu

PrettyPrinter:
Excellent for PHP arrays. The list of options for fomatting can be a little overwhelming but very powerful. I generally click the first two boxes for "Add new lines after "{" and before "}" " and "Add new lines before "{" "
prettyprinter.de

Phillihp's PHP Pretty Printer:
Admittedly, this tool is down every once in awhile. It's a bummer because I haven't found a better one. This handles PHP Objects beautifully, and color codes them too.
http://phillihp.com/toolz/php-array-beautifier/

It is also worth noting that the Javascript method JSON.stringify() is capable of pretty-printing JSON objects.   JSON.stringify(JSON_object, null, 2);    ( I don't remember what the null is for but the 2 is the amount of indentation I believe )

Firebug and the Chrome Developers Console also have good methods for formatting debugging output:
https://getfirebug.com/wiki/index.php/Console_API
https://developers.google.com/chrome-developer-tools/docs/console

If you have a favorite, please leave a comment.

No comments:

Post a Comment