Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

6
  • actually I do the same but with javascript itself :) Commented Dec 9, 2008 at 8:55
  • 2
    In the version of the JSON module I have, to_json doesn't seem to accept options. But this works: perl -MJSON -nE 'say JSON->new->pretty->encode(from_json $_)' text.json Commented Dec 16, 2011 at 15:12
  • 2
    The Python example could be simplified. It's much easier to pipe JSON output straight into python -m json.tool. Commented Mar 17, 2014 at 2:28
  • @Dan: yes. And there are several answers that show json.tool code examples. 1. this version allows you to change some parameters e.g., indent 2. At the time of the posting (2008) Python 2.4 was still used that doesn't support -mjson.tool Commented Mar 17, 2014 at 7:21
  • 1
    @dwlz command-line version with unicode characters (requires python3.9+): python -m json.tool --no-ensure-ascii in.json out.json Commented Mar 30, 2023 at 12:53