DEV Community

Bùi Quang
Bùi Quang

Posted on

JSON Lens CLI: A Lightweight Python Tool for JSON Validation and Formatting

JSON Lens CLI: A Lightweight Python Tool for JSON Validation, Formatting and Stats

Managing and inspecting large JSON files can be tedious. Today, I'm releasing JSON Lens CLI (json-lens-cli), an open-source, zero-dependency Python command-line utility designed to make inspecting, validating, formatting, and analyzing JSON files lightning fast.

Features

  1. Validation: Quickly verify if any JSON file or string is syntactically valid.
  2. Statistics: Inspect key metrics including total size, number of keys, root type, and maximum nesting depth.
  3. Pretty Print & Minify: Format raw JSON with custom indentation or compress it for storage and network transmission.

Installation & Usage

You can clone the repository from GitHub:

git clone https://github.com/qtnt2xxx-wq/json-lens-cli.git
cd json-lens-cli
Enter fullscreen mode Exit fullscreen mode

Validate a JSON file

python3 cli.py validate data.json
Enter fullscreen mode Exit fullscreen mode

Inspect JSON Stats

python3 cli.py stats data.json
Enter fullscreen mode Exit fullscreen mode

Format / Pretty Print

python3 cli.py format data.json --indent 4
Enter fullscreen mode Exit fullscreen mode

Open Source & Contribution

The project is completely open source under the MIT License. Contributions, issues, and pull requests are welcome on GitHub!

Top comments (0)