DEV Community

yyossy
yyossy

Posted on

Edit .json.gz Files Effortlessly with jgze – A Flexible CLI Tool

Working with .json.gz files can be tedious, especially when you need to extract, edit, and recompress them manually. Meet jgze, a command-line tool that simplifies this process by allowing you to directly edit .json.gz files in a seamless workflow.

https://github.com/teihenn/jgze

What is jgze?

jgze is a CLI tool designed to let you edit .json.gz files without the hassle of separate decompression and recompression steps. It also provides flexibility in handling file formats during the editing process.

Key Features

  • Direct Editing: Open and edit .json.gz files as if they were plain JSON files.
  • Pretty Formatting During Editing: Regardless of the original file's format (compact or JSON Lines), the tool presents the content in a pretty-printed, readable structure during editing.
  • Automatic Reformatting: After editing, jgze saves the file back to its original format (e.g., compact, pretty-printed, or JSON Lines).

Usage

  1. Run jgze to open your .json.gz file in your preferred editor.(default: vim)
  2. Edit the content in a pretty-printed format for easier readability.
  3. Save and close – the file will automatically be compressed and reformatted to its original structure.
# Example usage
jgze your_file.json.gz
Enter fullscreen mode Exit fullscreen mode

Example: Compact to Pretty and Back to Compact

  • Original (Compact Format):
{"key1":"value1","key2":"value2","key3": "value3"}
Enter fullscreen mode Exit fullscreen mode
  • Editing (Pretty Format):
{
  "key1": "value1",
  "key2": "value2",
  "key3": "value3"
}
Enter fullscreen mode Exit fullscreen mode

Suppose you edited this as follows:

{
  "key1": "value1",
  "key2": "value2"
}
Enter fullscreen mode Exit fullscreen mode
  • Saved File (Reverted to Compact):
{"key1":"value1","key2":"value2"}
Enter fullscreen mode Exit fullscreen mode

Why Use jgze?

Traditional workflows with .json.gz files require decompression, manual editing, and recompression – a repetitive and error-prone process. With jgze, you can:

  • Save time by skipping manual steps.
  • Easily read and edit JSON content in pretty-printed format.
  • Preserve the file’s original format, ensuring compatibility with downstream systems.

Installation

You can install jgze via Cargo or download the pre-built binaries from the GitHub releases page.

# Install via Cargo
cargo install jgze
Enter fullscreen mode Exit fullscreen mode

Alternatively, download the appropriate binary for your platform from the GitHub repository.

Example Use Case

Imagine you're working with large .json.gz files. Instead of juggling multiple tools, use jgze to directly edit and maintain the file format.

Get Started

jgze is open-source and available on GitHub. Feel free to explore the repository.

Image of AssemblyAI

Automatic Speech Recognition with AssemblyAI

Experience near-human accuracy, low-latency performance, and advanced Speech AI capabilities with AssemblyAI's Speech-to-Text API. Sign up today and get $50 in API credit. No credit card required.

Try the API

Top comments (0)

Heroku

Simplify your DevOps and maximize your time.

Since 2007, Heroku has been the go-to platform for developers as it monitors uptime, performance, and infrastructure concerns, allowing you to focus on writing code.

Learn More

👋 Kindness is contagious

Engage with a sea of insights in this enlightening article, highly esteemed within the encouraging DEV Community. Programmers of every skill level are invited to participate and enrich our shared knowledge.

A simple "thank you" can uplift someone's spirits. Express your appreciation in the comments section!

On DEV, sharing knowledge smooths our journey and strengthens our community bonds. Found this useful? A brief thank you to the author can mean a lot.

Okay