Skip to content

rxzzh/jsonskim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

jsonskim

CI License: MIT

中文文档

UNIX-style JSON Structure Extractor — Collapse arrays and truncate strings for human/LLM readability.

Keywords: JSON schema extractor, JSON structure viewer, JSON skeleton, reduce JSON for LLM, JSON minifier, JSON simplifier, production JSON analyzer, API response structure, JSON to schema, large JSON viewer

Features

  • 🚀 Single Binary — Zero dependencies, ~700KB static executable
  • 📦 Array Collapse — Retain only the first N elements of arrays
  • ✂️ String Truncation — Automatically truncate long strings
  • 🔧 UNIX Philosophy — stdin/stdout compatible, composable with other tools
  • 🎯 LLM Ready — Output optimized for AI/human comprehension

Installation

Pre-built Binaries

Download from GitHub Releases.

Platform Binary
Windows x64 jsonskim-windows-x86_64.exe
Linux x64 jsonskim-linux-x86_64
macOS x64 jsonskim-darwin-x86_64
macOS ARM jsonskim-darwin-aarch64

From Source

cargo install --path .

Usage

# Read from file
jsonskim data.json

# Read from stdin
cat huge_production_data.json | jsonskim

# Pipe from curl
curl -s https://api.example.com/data | jsonskim

Options

Usage: jsonskim [OPTIONS] [FILE]

Arguments:
  [FILE]  Input JSON file (reads from stdin if not provided)

Options:
  -l, --limit <N>         Array collapse limit: retain first N items [default: 1]
  -s, --string-limit <N>  Truncate strings longer than N chars [default: 64, 0 = no limit]
  -c, --compact           Output compact JSON instead of pretty-printed
  -h, --help              Print help
  -V, --version           Print version

Examples

# Extract structure with default settings
jsonskim production_log.json

# Keep 2 array samples, truncate strings at 100 chars
jsonskim -l 2 -s 100 data.json

# Compact output for LLM consumption
cat api_response.json | jsonskim -c

# No string truncation
jsonskim -s 0 config.json

Example Output

Input (imagine millions of users):

{
  "status": "success",
  "users": [
    {"id": 1, "name": "Alice", "bio": "AAAA...1000 chars..."},
    {"id": 2, "name": "Bob", "bio": "BBBB...1000 chars..."},
    "... 10000 more users ..."
  ],
  "logs": ["Log 1", "Log 2", "... 5000 more logs ..."]
}

Output (jsonskim -l 1 -s 20):

{
  "status": "success",
  "users": [
    {
      "id": 1,
      "name": "Alice",
      "bio": "AAAAAAAAAAAAAAAAAAAA...<truncated_len_1000>"
    }
  ],
  "logs": ["Log 1"]
}

Use Cases

Scenario Command
LLM Context Preparation cat api.json | jsonskim -c | clipboard
API Schema Discovery curl api.example.com | jsonskim
Log Structure Analysis jsonskim -l 3 huge_log.json
Documentation Generation jsonskim -s 0 sample.json > schema.json

MCP Integration

Use jsonskim via MCP (Model Context Protocol):

{
  "mcpServers": {
    "jsonskim": {
      "command": "npx",
      "args": ["-y", "jsonskim-mcp"]
    }
  }
}

See mcp/README.md for details.

Related Tools

  • jq — JSON query and transformation
  • gron — Make JSON greppable

License

MIT


SEO: What problems does jsonskim solve?
  • How to extract JSON schema from data?
  • How to view large JSON file structure?
  • How to reduce JSON size for LLM context?
  • How to collapse arrays in JSON?
  • How to truncate long strings in JSON?
  • JSON structure extractor for AI/ChatGPT
  • View production JSON without loading entire file
  • Extract JSON skeleton for documentation

About

No description, website, or topics provided.

Resources

License

Contributing

Stars

Watchers

Forks

Packages

No packages published