Tools do not have to be big to be a great help. One of those little helpers I use often when working with XML and JSON is Indent XML. It is a plugin for Sublime Text (a sophisticated text editor) and helps you to turn this
1 |
<root><node attr="1" ><node attr2="4"/></node><node>hello</node></root> |
into this
1 2 3 4 5 6 |
<root> <node attr="1"> <node attr2="4"/> </node> <node>hello</node> </root> |
If you work with JSON, you can do the same and turn this
1 |
{ "root": [ { "field": "val1", "field2": "val2" }, { "arr": [1, 3, "three"] }] } |
into this more readable structure:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
{ "root": [ { "field": "val1", "field2": "val2" }, { "arr": [ 1, 3, "three" ] } ] } |
You can install this plugin using Package Control for Sublime Text 2 and 3. Select the block of JSON or XML you want to indent and call it over the selection menu:
That is all you need to do and you no longer have to work with long lines of JSON or XML. Try it!