9 releases

0.2.7 Nov 11, 2024
0.2.6 Sep 10, 2024
0.2.5 Aug 31, 2024
0.1.0 Aug 15, 2024

#335 in Parser implementations

Download history 51/week @ 2024-08-09 528/week @ 2024-08-16 33/week @ 2024-08-23 227/week @ 2024-08-30 144/week @ 2024-09-06 36/week @ 2024-09-13 4/week @ 2024-09-20 36/week @ 2024-09-27 6/week @ 2024-10-04 117/week @ 2024-11-08 17/week @ 2024-11-15 3/week @ 2024-11-22

137 downloads per month

MIT license

28KB
555 lines

๐Ÿงน tidy-json

A cli tool for sorting JSON files.

Install

brew install todor-a/tap/tidy-json 
curl --proto '=https' --tlsv1.2 -LsSf https://github.com/todor-a/tidy-json/releases/download/v0.1.0/tidy-json-installer.sh | sh

Usage

tidy-json **/*.json --write

Options

Usage: tidy-json [OPTIONS] <INCLUDE>...

Arguments:
  <INCLUDE>...  File patterns to process (e.g., *.json)

Options:
  -e, --exclude <EXCLUDE>            File patterns to exclude (e.g., *.json)
  -w, --write                        Write the sorted JSON back to the input files
  -b, --backup                       Create backups before modifying files
  -d, --depth <DEPTH>                Specify how deep the sorting should go
  -o, --order <ORDER>                Specify the sort order [default: asc] [possible values: asc, desc, rand]
  -i, --indent <INDENT>              Specify the desired indent
      --indent-style <INDENT_STYLE>  Specify the desired indent style [possible values: tabs, spaces]
  -h, --help                         Print help
  -V, --version                      Print version

Example

$ tidy-json **/*.json

Before After
{
  "b": 1,
  "a": 2,
  "c": 3
}
{
  "a": 2,
  "b": 1,
  "c": 3
}

$ tidy-json **/*.json --depth=1

Before After
{
  "b": 1,
  "a": {
    "b": 1,
    "a": 2,
    "c": 3
  },
  "c": 3
}
{
  "a": {
    "b": 1,
    "a": 2,
    "c": 3
  },
  "b": 1,
  "c": 3
}

Dependencies

~7โ€“16MB
~214K SLoC