How to make output of JsonObject in Java console more readable?

You can take a look at elemental.json.impl.JsonUtil.stringify(...) methods

So you would change the System out line?

I would add return JsonUtil.stringify(encodedCredential); in the last line.

I did but nothing changed. It is exactly the same output like before.

Did you look at all the stringify overloads? Have you specified the indent parameter?

There is a library called Underscore which has methods to format ( prettty print ) this JSON