Command Line Interface (CLI) Reference
jsonette provides a high-performance, standalone Command Line Interface (CLI) built on top of the core Rust engine. It allows formatting, minifying, querying, and managing configuration settings directly in your terminal.
🚀 Installation
Once published, you can install the CLI directly:
Cargo (Rust)
Homebrew (macOS / Linux)
Pre-compiled Binaries (GitHub Releases)
If you prefer not to use a package manager or cargo, you can download standalone binaries directly from our GitHub Releases page.
- Go to the Releases page.
- Download the binary that matches your operating system and architecture (e.g.,
jsonette-macos-arm64for Apple Silicon,jsonette-linux-amd64for Linux, orjsonette-windows-amd64.exefor Windows). - Make the binary executable (on Unix systems) and move it to your PATH:
# Example for macOS Apple Silicon
🛠️ Commands & Usage
1. Formatting & Minifying
Formats (pretty-prints) or minifies a JSON file or standard input.
# Format a JSON file (outputs to stdout)
# Format standard input via pipeline
|
# Minify JSON (remove all whitespace)
# Output formatted JSON to a new file
# Format in-place (updates the file directly)
Formatting Option Overrides
You can override your global configuration for a single command run using the following flags:
-o, --output <file>: Write output to a specific file instead of standard output.-i, --in-place: Edit the input file in-place (mutually exclusive with--output).-s, --sort-keys <true|false>: Sort object keys alphabetically.-n, --indent <count>: Set the number of spaces/tabs for indentation.--use-tabs <true|false>: Use tab characters instead of spaces.--line-ending <lf|crlf>: Force a specific line ending style.--folding-style <expanded|compact>: Customize folding behavior.
2. Querying JSON (JSONPath)
Evaluate RFC 9535 JSONPath expressions against a JSON document.
# Query a file
# Query standard input
|
3. Exploring JSON Structure (explore)
For unfamiliar JSON structures, explore allows you to discover keys or array lengths without needing to know them in advance.
# View the keys at the root of a JSON file (defaults to '$')
# View keys of an object at a specific path
# Filter keys matching a regex and limit the output to 5 items
4. Converting JSON (convert)
Convert a JSON document into other serialization formats (YAML, TOML, XML).
# Convert a JSON file to YAML
# Convert a JSON file to TOML
# Convert standard input to XML
|
5. Generating Dummy Data (generate)
Generate structured dummy JSON data from a schema file.
# Generate dummy JSON based on schema
# Generate a 10MB dummy JSON object and write to a file
6. Global Config Management
Manage your global settings file (~/.config/jsonette/settings.json or %LOCALAPPDATA%\jsonette\settings.json) directly from the command line.
# List all active settings in JSON format
# Get a specific configuration key
# Set a configuration key (persists to disk)
7. Shell Autocompletion (completions)
Dynamically generates autocompletion scripts for various shells including bash, zsh, fish, powershell, and elvish.
# Generate zsh autocompletions (prints to stdout)
# Load completions immediately in your current zsh session
# Install completions permanently (macOS/Homebrew zsh setup)
⚠️ Diagnostics & Error Output
When formatting or parsing invalid JSON, jsonette outputs detailed diagnostics to stderr with line/column coordinates and a compiler-style visual caret pointer:
Error in <stdin>:2:1: EOF while parsing an object at line 2 column 0
|
1 | {"a": 1
| ^
- Exit code
0is returned on success. - Exit code
1is returned on parsing, evaluation, or syntax errors.