{"id":49089643,"url":"https://github.com/rick-does/json-razor","last_synced_at":"2026-04-20T18:00:35.598Z","repository":{"id":350894131,"uuid":"1208646072","full_name":"rick-does/json-razor","owner":"rick-does","description":"Reduces JSON, YAML, and NDJSON volume by collapsing repeated structures while preserving the schema, making the schema easier for you to read.","archived":false,"fork":false,"pushed_at":"2026-04-20T13:36:21.000Z","size":46,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-04-20T15:27:14.551Z","etag":null,"topics":["cli","data","devtools","json","logs","ndjson","schema","yaml"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rick-does.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-04-12T15:09:14.000Z","updated_at":"2026-04-20T13:36:26.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/rick-does/json-razor","commit_stats":null,"previous_names":["rick-does/json-razor"],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/rick-does/json-razor","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rick-does%2Fjson-razor","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rick-does%2Fjson-razor/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rick-does%2Fjson-razor/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rick-does%2Fjson-razor/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rick-does","download_url":"https://codeload.github.com/rick-does/json-razor/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rick-does%2Fjson-razor/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32059139,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-20T11:35:06.609Z","status":"ssl_error","status_checked_at":"2026-04-20T11:34:48.899Z","response_time":94,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cli","data","devtools","json","logs","ndjson","schema","yaml"],"created_at":"2026-04-20T18:00:18.174Z","updated_at":"2026-04-20T18:00:35.577Z","avatar_url":"https://github.com/rick-does.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# JSON's Razor — Cut the fat\n\n[![tests](https://github.com/rick-does/json-razor/actions/workflows/tests.yml/badge.svg)](https://github.com/rick-does/json-razor/actions/workflows/tests.yml)\n\nReduces JSON, YAML, and NDJSON volume by collapsing repeated structures while preserving the schema, making the schema easier for you to read.\n\nLarge structured data files are hard to parse — not because the structure is complex, but because repetition obscures it. A list of 10,000 objects with identical shape tells you nothing more than a list of 1. JSON's Razor collapses that repetition to its minimum essential form: one representative example of each repeated structure, at every level of nesting.\n\nThe output is valid, parseable data in the same format as input — not a summary, not a schema definition. It just has far less volume.\n\n---\n\n## Install\n\n```bash\npip install json-razor\n```\n\n---\n\n## Usage\n\n```bash\ncat big.json | json-razor                    # stdin → stdout\njson-razor big.json                          # file input → stdout\njson-razor big.json -o small.json            # file input → file output\njson-razor big.yaml                          # auto-detected as YAML\njson-razor app.log --format ndjson           # NDJSON log file\n```\n\n### Options\n\n| Flag | Default | Description |\n|------|---------|-------------|\n| `--keep N` | 1 | Number of examples to keep per repeated structure |\n| `--depth N` | unlimited | Stop collapsing below this nesting depth |\n| `--format` | auto | Force format: `json`, `yaml`, or `ndjson` |\n| `--truncate N` | 100 | Max string length before truncating |\n\n---\n\n## How it works\n\n**Arrays** — collapsed to one item. Mixed-type arrays keep one of each distinct type.\n\n```json\n// input\n[{\"id\": 1, \"name\": \"alice\"}, {\"id\": 2, \"name\": \"bob\"}, {\"id\": 3, \"name\": \"carol\"}]\n\n// output\n[{\"id\": 1, \"name\": \"alice\"}]\n```\n\n**Mixed types** — one representative per JSON type (null, bool, number, string, array, object).\n\n```json\n// input\n[1, \"hello\", {\"id\": 1}, null, true, [1, 2, 3]]\n\n// output\n[1, \"hello\", {\"id\": 1}, null, true, [1]]\n```\n\n**Nested structures** — collapsed recursively at every level.\n\n**NDJSON** — collapsed across lines; one representative line kept.\n\n**Nulls and empty values** — always preserved (`null`, `[]`, `{}`).\n\n**Long strings** — truncated to a configurable preview.\n\n---\n\n## Supported formats\n\n| Format | Auto-detected from |\n|--------|--------------------|\n| JSON | `.json` |\n| YAML | `.yaml`, `.yml` |\n| NDJSON | `.ndjson` |\n\n---\n\n## Use case: OpenAPI specs\n\nOpenAPI specs are a natural fit for JSON's Razor. They're long, deeply nested, and repeat the same response structures across dozens of endpoints.\n\nRun the included sample to see it in action:\n\n```bash\njson-razor tests/samples/openapi.yaml\n```\n\nYou get the full API shape — every path, method, status code, and referenced schema — without the repetition that obscures it. Useful for:\n\n- Reviewing an unfamiliar API quickly\n- Inspecting generated specs in CI before they're published\n- Diffing structural changes between spec versions\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frick-does%2Fjson-razor","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frick-does%2Fjson-razor","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frick-does%2Fjson-razor/lists"}