Tools: json-key-parser vs jsonpath-ng: Simplicity Wins for Messy JSON, Power for Complex Queries

Tools: json-key-parser vs jsonpath-ng: Simplicity Wins for Messy JSON, Power for Complex Queries

Source: Dev.to

1. Philosophy & API ## 2. Power & Features ## 3. Dependencies & Size ## 4. Performance & Maturity ## When to Choose Which ## Bottom Line 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. json-key-parser example (the one-liner magic): Done. It recursively hunts every level, handles lists, merges duplicate keys into lists automatically. jsonpath-ng equivalent (you need multiple expressions or clever wildcards): You then have to extract .value from Match objects and handle merging yourself. Winner for quick-and-dirty extraction: json-key-parser. json-key-parser shines when: jsonpath-ng dominates when: jsonpath-ng also supports extensions for len(), keys(), sorting, etc. Both are zero external dependencies now. Both install with one pip command and support Python 3.8+. 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. Use json-key-parser if: 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. 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. 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. Templates let you quickly answer FAQs or store snippets for re-use. Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink. Hide child comments as well For further actions, you may consider blocking this person and/or reporting abuse CODE_BLOCK: from json_parser import JsonParser result = JsonParser(data, ["first_name", "street", "address*"]).get_data() Enter fullscreen mode Exit fullscreen mode CODE_BLOCK: from json_parser import JsonParser result = JsonParser(data, ["first_name", "street", "address*"]).get_data() CODE_BLOCK: from json_parser import JsonParser result = JsonParser(data, ["first_name", "street", "address*"]).get_data() COMMAND_BLOCK: 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 Enter fullscreen mode Exit fullscreen mode COMMAND_BLOCK: 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 COMMAND_BLOCK: 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 COMMAND_BLOCK: pip install json-key-parser Enter fullscreen mode Exit fullscreen mode COMMAND_BLOCK: pip install json-key-parser COMMAND_BLOCK: pip install json-key-parser - 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 - 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 - json-key-parser: pure stdlib, < 50 KB installed - jsonpath-ng: robust parser (no longer pulls in ply at runtime in recent versions), still tiny - 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. - 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 - 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