Some of you may know that json-key-parser (v0.1.0, released Feb 18, 2026) is the tiny, zero-dependency hero that lets you yank specific keys out of deeply nested JSON with almost zero effort.
But the Python ecosystem already has a heavyweight champion: jsonpath-ng (v1.8.0, released Feb 24, 2026). It’s the full-featured JSONPath implementation that’s been battle-tested for years.
So which one should you actually reach for? Let’s compare them head-to-head on the things that matter.
1. Philosophy & API
| Aspect | json-key-parser | jsonpath-ng |
|---|---|---|
| Core idea | “Just give me these keys, wherever they are” | “Write a precise path query like XPath for JSON” |
| Syntax | Simple list of strings + * wildcard |
Full JSONPath expressions ($..key, [*], ?(@.price>10)) |
| Learning curve | 30 seconds | 15–30 minutes + docs |
| Typical line count | 1–2 lines | 3–10+ lines (parse + find + process) |
json-key-parser example (the one-liner magic):
from json_parser import JsonParser
result = JsonParser(data, ["first_name", "street", "address*"]).get_data()
Done. It recursively hunts every level, handles lists, merges duplicate keys into lists automatically.
jsonpath-ng equivalent (you need multiple expressions or clever wildcards):
from jsonpath_ng import parse
first_names = parse('$..first_name').find(data)
streets = parse('$..street').find(data)
addresses = parse('$..address*').find(data) # Note: * works but not exactly the same
You then have to extract .value from Match objects and handle merging yourself.
Winner for quick-and-dirty extraction: json-key-parser.
2. Power & Features
json-key-parser shines when:
- JSON structure is unpredictable or changes often (third-party APIs, logs, scraped data)
- You just want a flat dict/list of the fields you care about
- Duplicate keys appear at different nesting levels (it merges them intelligently)
- You hate writing defensive
data.get("a", {}).get("b", [])chains
jsonpath-ng dominates when:
- You need filters:
$.books[?(@.price > 20)] - You want to update or delete values in place:
expr.update(data, new_value) - You need arithmetic, regex, slicing, or parent references
- You’re doing metaprogramming (it exposes a clean AST)
- You want full paths back:
match.full_path
jsonpath-ng also supports extensions for len(), keys(), sorting, etc.
3. Dependencies & Size
Both are zero external dependencies now.
- json-key-parser: pure stdlib, < 50 KB installed
- jsonpath-ng: robust parser (no longer pulls in ply at runtime in recent versions), still tiny
Both install with one pip command and support Python 3.8+.
4. Performance & Maturity
- jsonpath-ng is mature, heavily tested, and used in production everywhere.
- json-key-parser is brand new (Beta status) but laser-focused, so its recursion is extremely fast for the 95% use case.
For massive JSON documents with thousands of nested objects, jsonpath-ng’s compiled expressions can edge it out on complex queries. For simple key extraction? json-key-parser is often faster because it doesn’t parse a query language at all.
When to Choose Which
Use json-key-parser if:
- You’re writing ETL scripts, API clients, or data-cleaning notebooks
- Your JSON is messy and you just want “first_name, email, total” regardless of nesting
- You value readability and minimal code
Use jsonpath-ng if:
- You need conditional filtering or data transformation
- You’re building a library or tool that requires precise, repeatable queries
- You want to modify the JSON structure in place
Pro tip: You can even use both in the same project! Parse once with jsonpath-ng for complex stuff, then hand the result off to json-key-parser for final flattening.
Bottom Line
If jsonpath-ng is the Swiss Army knife of JSON querying, json-key-parser is the precision scalpel for the single most common pain point: “I just need these damn keys.”
For 80% of real-world Python scripts dealing with APIs and configs, json-key-parser will save you more time and frustration than any other library released this year.
Try it right now:
pip install json-key-parser
Then compare it yourself with the exact same data in both libraries. I bet you’ll delete a bunch of boilerplate within five minutes.
What’s your biggest JSON-parsing headache right now? Drop it in the comments — I’ll show you which tool slays it faster.
Top comments (0)