Skip to main content

jsonx

JSON query and transform CLI — simpler than jq.

PyPI version

Installation

pip install jsonx-cli

For JSON Schema validation:

pip install jsonx-cli[schema]

Quick Start

# Get a nested value
jsonx get .users[0].name data.json

# From stdin
cat data.json | jsonx get .config.debug

# Set a value
jsonx set .config.debug true data.json

# List all keys
jsonx keys data.json

# Pretty print
jsonx format data.json

Path Syntax

jsonx uses simple dot notation:

Pattern Meaning
.key Object property
.nested.key Nested property
[0] Array index
[-1] Last array item
[*] All array items
[0:3] Array slice

Examples:

jsonx get .name data.json           # Get "name" property
jsonx get .users[0] data.json       # First user
jsonx get .users[-1] data.json      # Last user
jsonx get .users[*].email data.json # All user emails
jsonx get .items[0:5] data.json     # First 5 items

Commands

get - Extract values

jsonx get .path [file]          # Extract value at path
jsonx get .path file --raw      # Raw output (no quotes)
jsonx get .path file --json     # Force JSON output

set - Modify values

jsonx set .path value [file]    # Set and output
jsonx set .path value file -i   # Modify in place
jsonx set .path value file -o out.json  # Write to file

Value is parsed as JSON:

jsonx set .debug true data.json           # boolean
jsonx set .count 42 data.json             # number
jsonx set .name '"Alice"' data.json       # string (note quotes)
jsonx set .tags '["a","b"]' data.json     # array

del - Delete values

jsonx del .path [file]          # Delete and output
jsonx del .path file -i         # Delete in place

keys - List keys

jsonx keys [file]               # Top-level keys
jsonx keys file -r              # All keys recursively

flatten / unflatten - Structure transformation

# Flatten nested structure
jsonx flatten data.json
# {"users[0].name": "Alice", "config.debug": true}

# Unflatten back
echo '{"user.name": "Alice"}' | jsonx unflatten
# {"user": {"name": "Alice"}}

merge - Combine files

jsonx merge base.json override.json     # Deep merge
jsonx merge a.json b.json --shallow     # Shallow merge

diff - Compare files

jsonx diff old.json new.json
# + config.newKey: "value"      (green - added)
# - config.removed: true        (red - removed)  
# ~ config.changed: 1 → 2       (yellow - changed)

format / minify - Pretty print

jsonx format data.json              # Pretty print
jsonx format data.json -i 4         # 4-space indent
jsonx minify data.json              # Compact

validate - JSON Schema

jsonx validate data.json schema.json
# ✓ Valid
# or
# ✗ Invalid: 'email' is required

type - Show value type

echo '[]' | jsonx type        # array
echo '{}' | jsonx type        # object
echo '42' | jsonx type        # integer

count - Count items

jsonx count data.json                     # Top-level count
jsonx get .users data.json | jsonx count  # Count array items

each - Iterate arrays

# Output each item as JSON
jsonx each data.json -p .users

# With template
jsonx each data.json -p .users -t '{.name}: {.email}'

Piping

jsonx works great in pipelines:

# Extract, transform, merge
cat config.json | jsonx get .database | jsonx set .host '"prod.db"'

# Count users
jsonx get .users data.json | jsonx count

# Extract all emails
jsonx get .users[*].email data.json

# Filter and format
curl api/data | jsonx get .results | jsonx format

For AI Agents

See SKILL.md for agent-optimized documentation.

Exit Codes

  • 0 - Success
  • 1 - Error (invalid JSON, path not found, etc.)

License

MIT

Release files for jsonx-cli 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for jsonx-cli 0.1.0
File Size Uploaded
jsonx_cli-0.1.0.tar.gz 9.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for jsonx-cli 0.1.0
File Interpreter ABI Platform
jsonx_cli-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 20.5 kB

Release files / jsonx_cli-0.1.0.tar.gz

Download URL jsonx_cli-0.1.0.tar.gz
Size 9.9 kB
Tags Source
SHA-256 checksum
How to use checksums
a05dee79c34ef5649c8d12df1b097ed22f7b8ecfb65836d7d98c52db6d5a0c32
BLAKE2b-256 checksum
How to use checksums
caf69a73186297aa191a540ff86ec0d93b286c4bfc19c6c2bde4cfb9a37387e1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.12

Release files / jsonx_cli-0.1.0-py3-none-any.whl

Download URL jsonx_cli-0.1.0-py3-none-any.whl
Size 10.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ed9f00b3de29fbc6ba3f43ff880b09d5b0beaddcec64fdb99cefe71689a6762f
BLAKE2b-256 checksum
How to use checksums
2c87a8b5e14f2c8381623b3bd84fb171146e8e2858c80cdfbd903b090c75029c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.12

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page