Pretty printing is surprisingly tricky.  Last time I had to do it, I ended up with this: <a href="https:&#x2F;&#x2F;github.com&#x2F;rethinkdb&#x2F;rethinkdb&#x2F;blob&#x2F;next&#x2F;src&#x2F;pprint&#x2F;pprint.cc" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;rethinkdb&#x2F;rethinkdb&#x2F;blob&#x2F;next&#x2F;src&#x2F;pprint&#x2F;...</a> which has become my favorite algorithm for it as it&#x27;s quite tweakable for specific needs.  Fun little algorithm.