Is there a CLI tool that would prettify a JSON string

cat file.json | json_pp  #perl utility
cat file.json | jq .    

jq packs much more than just pretty-printing abilities.


I would pipe that into yaml (which is part of ruamel.yaml of which I am the author):

echo $ENV_VAR | base64 --decode | yaml from-json -

will give you this (based on your example output):

second_database:
- username: user
  password: ''
  ip: 123.4.567.89
  host: second_database.internal
  path: main
  query:
    is_master: true
  scheme: mysql
  port: 3306
redis:
- ip: 123.4.567.89
  host: redis
  scheme: redis
  port: 6379
something:
- path: something
  host: something.internal
  scheme: solr
  port: 8080
  ip: 123.4.567.89
database:
- username: user
  password: ''
  ip: 123.4.567.89
  host: database.internal
  path: main
  query:
    is_master: true
  scheme: mysql
  port: 3306

The ordering of the keys is not guaranteed, because it is not guaranteed in json and I don't have a ruamel.json package like ruamel.yaml that preserves order when reading in json.

The above works on the principle that YAML is a superset of JSON, but has more readable display modes (leaving out quotes when not absolutely necessary, making indented block structure).