Skip to content
/ jgze Public

A lightweight CLI tool to edit .json.gz files seamlessly. Edit gzipped JSON files directly in your favorite editor with automatic formatting and compression handling.

License

Notifications You must be signed in to change notification settings

teihenn/jgze

Repository files navigation

jgze

Crates.io Downloads License

A lightweight CLI tool to edit .json.gz files seamlessly. Edit gzipped JSON files directly in your favorite editor with automatic formatting and compression handling.

Features

  • Edit .json.gz files directly using your preferred text editor
  • Automatically formats compact JSON for better readability while editing
  • Preserves the original format (compact/pretty) after saving
  • Validates JSON syntax after editing
  • Supports custom editor selection (defaults to vim)

Supported JSON Formats

The tool supports three JSON formats:

  1. Compact JSON (single line)
{"name":"John","age":30,"city":"Tokyo"}
  1. Pretty-printed JSON
{
  "name": "John",
  "age": 30,
  "city": "Tokyo"
}
  1. JSON Lines (JSONL)
{"name":"John","age":30}
{"name":"Alice","age":25}
{"name":"Bob","age":35}

For better readability, all formats are automatically converted to pretty-printed format when opened in the editor. After saving, the file is converted back to its original format before compression.

For example, if you open a compact JSON file:

  1. Original: {"name":"John","age":30,"city":"Tokyo"}
  2. While editing:
{
"name": "John",
"age": 30,
"city": "Tokyo"
}

Suppose you edited this as follows:

{
"name": "John",
"age": 30
}
  1. After saving: {"name":"John","age":30}

Usage

jgze [OPTIONS] <FILE>
Option Short Description
--editor <EDITOR> -e Specify the editor to use (default: vim)
--help -h Display help message
--version -v Display version information

Examples

# Edit with default editor (vim)
jgze input.json.gz

# Edit with a specific editor
jgze -e nano input.json.gz

# Show version information
jgze -v

# Show help message
jgze -h

The usage can be verified using the test data in the testdata directory.

Installation

Using cargo

install, update

cargo install jgze

uninstall

cargo uninstall jgze

From GitHub releases

install, update

  • Linux (x86_64)
tar xz -C /usr/local/bin < <(curl -L https://github.com/teihenn/jgze/releases/latest/download/jgze-x86_64-unknown-linux-gnu.tar.gz)
  • macOS (x86_64)
tar xz -C /usr/local/bin < <(curl -L https://github.com/teihenn/jgze/releases/latest/download/jgze-x86_64-apple-darwin.tar.gz)
  • macOS (aarch64)
tar xz -C /usr/local/bin < <(curl -L https://github.com/teihenn/jgze/releases/latest/download/jgze-aarch64-apple-darwin.tar.gz)
  • Windows (x86_64)
  1. Download the latest release
  2. Extract the downloaded ZIP file
  3. Create a directory and place jgze.exe (e.g., C:\Program Files\jgze)
  4. Add the installation directory to the system PATH by running PowerShell as administrator

uninstall

ls -l /usr/local/bin/jgze
sudo rm /usr/local/bin/jgze

From source

install, update

git clone https://github.com/teihenn/jgze
cd jgze
cargo install --path .

uninstall

cargo uninstall jgze

How it works

  1. Decompresses the input .json.gz file
  2. Detects the JSON format and processes accordingly:
    • Compact JSON: Formats for better readability
    • JSONL: Formats each line individually
    • Pretty-printed JSON: Keeps as is
  3. Opens the formatted JSON in the specified editor
  4. After editing and saving:
    • Validates the JSON syntax
    • Converts based on original format:
      • For compact JSON: Compresses to single line
      • For JSONL: Compresses each object to single line
      • For pretty-printed JSON: Preserves formatting
    • Compresses with gzip and saves back to the original file

About

A lightweight CLI tool to edit .json.gz files seamlessly. Edit gzipped JSON files directly in your favorite editor with automatic formatting and compression handling.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages