| Crates.io | json-archive |
| lib.rs | json-archive |
| version | 0.99.1 |
| created_at | 2025-12-01 01:36:40.167613+00 |
| updated_at | 2025-12-02 05:02:14.534596+00 |
| description | CLI tool for tracking JSON file changes over time using delta-based archives |
| homepage | https://peoplesgrocers.com/code/oss/json-archive |
| repository | https://peoplesgrocers.com/code/oss/json-archive |
| max_upload_size | |
| id | 1959149 |
| size | 346,056 |
A practical CLI tool for tracking JSON file changes over time. Instead of keeping multiple copies of JSON files, this creates compact delta-based archives that preserve the complete history.
The problem I am solving: I have a JSON file that changes regularly (output of a scraping pipeline), and I want to track its history without storing dozens of full copies.
json-archive creates a .json.archive file next to your original JSON file. Each time you run the tool, it calculates only what changed and appends those deltas to the archive. You get complete history with minimal storage overhead. It can move a .json file into the archive or leave it untouched.
The archive format is human-readable JSONL (not binary), making it easy to inspect, debug, and pipe into other scripts or web visualizations.
# Create initial archive from data.json (infers output: data.json.archive)
json-archive data.json
# Later, append changes to existing archive
json-archive data.json.archive data.json
cargo install json-archive
Or build from source:
git clone <repo>
cd json-archive
cargo build --release
The format is JSONL with delta-based changes using JSON Pointer paths. For complete technical details about the file format, see the file format specification.
{"version": 1, "created": "2025-01-15T10:00:00Z", "initial": {"views": 100, "title": "My Video"}}
# First observation
["observe", "obs-001", "2025-01-15T10:05:00Z", 2]
["change", "/views", 100, 150, "obs-001"]
["change", "/title", "My Video", "My Awesome Video", "obs-001"]
# Second observation
["observe", "obs-002", "2025-01-15T11:00:00Z", 1]
["change", "/views", 150, 200, "obs-002"]
Each observation records:
/views)Hackable over efficient: The file format prioritizes human readability and scriptability over binary compactness. You can:
Minimal workflow changes: Archive files sit next to your original JSON files with a .archive extension. Your existing scripts need minimal modification.
Compression libraries are a security vulnerability vector. The default build includes them because I want convenience. If you don't want to bundle compression libraries:
cargo install json-archive --no-default-features
The minimal build detects compressed files and errors with a clear message explaining you need the full version or manual decompression.
While the file format keeps things simple and readable, the full build of this tool also works with compressed archives. You can read from and write to gzip, deflate, zlib, brotli, and zstd compressed files without special flags.
Important caveat: Compressed archives may require rewriting the entire file during updates (depending on the compression format). If your temporary filesystem is full or too small, updates can fail. In that case, manually specify an output destination with -o to write the new archive elsewhere. This works fine for the happy path with archive files up to a few hundred megabytes. Maybe think about custom code if you want to track gigabytes of changes.
Perfect for tracking YouTube video metadata over time:
# Download video info with yt-dlp
yt-dlp --write-info-json -o "%(id)s.%(ext)s" "https://youtube.com/watch?v=..."
# Create initial archive (creates videoID.info.json.archive)
json-archive videoID.info.json
# Later, append new observations to existing archive
json-archive videoID.info.json.archive videoID.info.json
# Or safely re-run (won't overwrite existing archive)
json-archive videoID.info.json
# Run daily in a cron job to capture changes
# The archive preserves your title/description experiments and view count history
The tool infers behavior from filenames:
# Create archive from JSON files (output inferred from first filename)
json-archive file1.json file2.json file3.json
# Creates: file1.json.archive
# Won't overwrite existing archives (safe to re-run)
json-archive data.json # Won't overwrite data.json.archive if it exists
# Force overwrite existing archive
json-archive --force data.json
# Specify custom output location
json-archive -o custom.archive data.json
# First file is archive, rest are appended
json-archive existing.json.archive new1.json new2.json
# Works with any mix of files
json-archive data.json.archive updated-data.json
# Add snapshots after 10 observations instead of default of 100 for faster append operations
json-archive -s 50 data.json
# Add source metadata
json-archive --source "youtube-metadata" data.json
Archives use the .json.archive extension by default:
<filename>.json -> <filename>.json.archiveThe strength of the file format is easy browser visualization:
// Parse archive in browser
fetch('data.json.archive')
.then(response => response.text())
.then(text => {
const lines = text.split('\n');
const header = JSON.parse(lines[0]);
const events = lines.slice(1)
.filter(line => line && !line.startsWith('#'))
.map(line => JSON.parse(line));
// Replay history, build visualizations, etc.
});
The format uses only standard JSON and organizes the data into roughly the shape you would need anyway.
Contributions are welcome! However, you will need to sign a contributor license agreement with Peoples Grocers before we can accept your pull request.
I promise to fix bugs quickly, but the overall design prioritizes being hackable over raw performance. This means many obvious performance improvements won't be implemented as they would compromise the tool's simplicity and inspectability.
Areas where contributions are especially appreciated:
This project is licensed under the GNU Affero General Public License v3.0 (AGPL-3.0). This means:
The AGPL ensures that improvements to this tool remain open and available to everyone, even when used in hosted services or embedded systems.