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

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.0.tar.gz (9.1 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.0-py3-none-any.whl (8.0 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for json_redactor-0.1.0.tar.gz
Algorithm Hash digest
SHA256 8a1e6eb3664f3e4ad3b87bb876305cfd25d4423c66d4bf16b747793c83f7c2e3
MD5 d4feb1ee097301727054e8f8774e0a98
BLAKE2b-256 32820290b6ea8943bd9ac19ff654aab39eb075a26c0885106efbd59e86b7059c

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for json_redactor-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b68165704a0702ee111373b449b1af0ee4039d7457c7e8117f769acd8a4d0fab
MD5 4aac46e1f9c1a2bd82948929574a28f7
BLAKE2b-256 bf517d4298af96651f32caab687c906a154b162e8e7d496075c9df0371aeffe3

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