>>> import json >>> x=[1,2,3] >>> print(json.dumps(x, sort_keys=True, indent=4)) [ 1, 2, 3 ]