Skip to main content

Add your description here

Project description

JSON Redactor

A streaming-safe command-line tool that redacts or hashes sensitive fields inside large JSON documents while preserving structure, order, and formatting.

Supports:

  • Arbitrarily nested JSON
  • Streaming processing (500MB+)
  • Case-insensitive key matching
  • Regex-based key matching
  • Deterministic SHA-256 hashing
  • Typing-friendly CLI via Typer
  • Optional parallel hashing

Features

Feature Description
Mask mode Replace values with "***REDACTED***"
Hash mode SHA-256 deterministic hashing
Regex matching --keys-regex "(?i)pass(word)?$"
Streaming-safe Uses ijson event parser; no full file load
Preserves structure Keeps object order, array order, keys
Large file support Safely processes files 500MB+
CLI script Installed as json-redactor

Installation

You can install the project either for development using uv or via pip from source.


Development install (uv)

uv sync

Run locally:

uv run -m json_redactor --help

Install from source (pip)

From the project root:

pip install .

Verify the CLI is installed:

json-redactor --help

Usage Examples

1. Redact specific keys (mask default)

cat people.json | json-redactor --keys email,password > out.json

Output:

{
  "email": "***REDACTED***",
  "password": "***REDACTED***"
}

2. Hash sensitive fields (deterministic SHA-256)

json-redactor data.json --keys ssn --hash

3. Use regex matching

json-redactor users.json --keys-regex '^pass' --mask

Matches: pass, password, passphrase, etc.


4. Load key names from file

secrets.txt:
email
ssn
token

Run:

json-redactor input.json --key-file secrets.txt --hash

5. Read from stdin explicitly

cat input.json | json-redactor -

Running Tests

Unit tests use pytest.

Run all tests:

pytest .

or

make test

Run with coverage:

pytest --cov=src --cov-report=term-missing

Project Structure

.
├── README.md
├── makefile
├── out.json
├── pyproject.toml
├── src
│   ├── json_redactor
├── tests
│   ├── __init__.py
│   └── test_core.py
└── uv.lock

CLI Reference

Usage: json-redactor [OPTIONS] [INPUT_PATH]

Redact or hash sensitive data in a JSON document.

Options:
  --keys TEXT           Comma-separated sensitive keys.
  --key-file PATH       File containing one key per line.
  --keys-regex TEXT     Regex patterns for key matching.
  --mask                Mask values as "***REDACTED***".
  --hash                Hash values using SHA-256.
  --help                Show this message and exit.

Example: Before & After

Input:

{
  "user": {
    "email": "anna@example.com",
    "ssn": "123-45-6789"
  }
}

Command:

json-redactor --keys email,ssn --hash

Output:

{
  "user": {
    "email": "06f14e0a6a3376d9104f...",
    "ssn": "5bf64d14db16bb7c8ca1..."
  }
}

Author

Yalchin JSON Redactor — Technical Assessment Implementation

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

json_redactor-0.1.1.tar.gz (9.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

json_redactor-0.1.1-py3-none-any.whl (8.0 kB view details)

Uploaded Python 3

File details

Details for the file json_redactor-0.1.1.tar.gz.

File metadata

  • Download URL: json_redactor-0.1.1.tar.gz
  • Upload date:
  • Size: 9.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.6

File hashes

Hashes for json_redactor-0.1.1.tar.gz
Algorithm Hash digest
SHA256 1006b85c5c98e814f29b18ea7a159d79ea0974db7fcc8d1daff48a766b288df0
MD5 ebb15d9da0bac418a299c84b120a2027
BLAKE2b-256 b9c6594d98a3820a3748618a77b1a168d9c0aca11ae611649a04df6e0e397a4a

See more details on using hashes here.

File details

Details for the file json_redactor-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: json_redactor-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 8.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.6

File hashes

Hashes for json_redactor-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ed002629bf7727513446eed6c587333d8ade37fc78abb57e880e014b1329cfec
MD5 003b2a043cbb790f7d68e333feb30899
BLAKE2b-256 b8e5cdb6e142f9068691e2e20af35f33b596db176681979365c3ee9baef56ff8

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page