LinuxCommandLibrary
GitHubF-DroidGoogle Play Store

python-m-json.tool

Validate and pretty-print JSON data

TLDR

Pretty print JSON
$ python -m json.tool [file.json]
copy
Format from stdin
$ echo '{"key":"value"}' | python -m json.tool
copy
Compact output
$ python -m json.tool --compact [file.json]
copy
Sort keys
$ python -m json.tool --sort-keys [file.json]
copy

SYNOPSIS

python -m json.tool [options] [file]

DESCRIPTION

python -m json.tool is a built-in Python module that validates and pretty-prints JSON data. It reads JSON from a file argument or standard input, checks for syntax errors, and outputs a formatted version with proper indentation for readability.The tool is useful for quickly inspecting API responses, configuration files, or any JSON output piped from other commands. Options control key sorting, indentation depth, and compact output mode. Since it ships with Python's standard library, it requires no additional installation.

PARAMETERS

FILE

JSON file to format.
--sort-keys
Sort object keys.
--compact
Compact output.
--indent N
Indentation level.
--no-ensure-ascii
Allow non-ASCII.

CAVEATS

Part of Python standard library. Basic functionality.

HISTORY

json.tool is a Python standard library module for JSON formatting.

SEE ALSO

jq(1), python(1)

Braincup
Open source brain training for math, memory and focus
Braincup mini-games
41 mini-games · Apache-2.0
No ads · No tracking
Play in browser
Download Braincup on the App StoreGet Braincup on Google PlayGet Braincup on F-Droid
276 stars
From the maker of Linux Command Library
Copied to clipboard
Braincup
Open source brain training for math, memory and focus. 41 mini-games, from mental arithmetic to Sudoku, N-Back and Solo Chess.
Apache-2.0 licensed · No ads · No tracking · No account
From the maker of Linux Command Library
Download Braincup on the App StoreGet Braincup on Google PlayGet Braincup on F-Droid