jsongrep: A DFA-Based JSON Query Tool That Outperforms jq in Benchmarks

✍️ OpenClawRadar📅 Published: March 27, 2026🔗 Source
jsongrep: A DFA-Based JSON Query Tool That Outperforms jq in Benchmarks
Ad

What jsongrep Does

jsongrep (jg binary) takes a query and a JSON input and prints every value whose path through the document matches the query. It treats JSON documents as trees where objects and arrays branch, scalars are leaves, and keys and indices label the edges. The query language is a regular language over the alphabet of keys and indices.

Query Language Features

Dot paths select nested fields by name: jg 'roommates[0].name' returns roommates.[0].name: "Alice".

Wildcards match any single key (*) or any array index ([*]): jg 'favorite_drinks[*]' returns all array elements.

Alternation (|) matches either branch: jg 'name | roommates' returns both fields.

Recursive descent uses * and [*] inside a Kleene star to walk arbitrarily deep: jg '(* | [*])*.name' finds every name field at any depth. The -F flag provides shorthand: jg -F name does the same.

Optional (?) matches zero or one occurrence: jg 'roommates[0].favorite_food?' returns both the parent object and the field value.

Ad

Technical Approach

jsongrep compiles queries into deterministic finite automata (DFA) using a pipeline that includes: parsing the query, treating JSON as a tree, constructing an NFA using Glushkov's algorithm, determinizing via subset construction, and searching using DFS with DFA transitions. This allows processing in a single pass with O(1) work per input symbol, avoiding backtracking, recursion stacks, and exponential blowup on pathological queries.

The author notes this differs fundamentally from tools like jq, jmespath, or jsonpath-rust, which interpret path expressions, evaluate queries at each node, check predicates, and recursively descend—potentially revisiting subtrees or maintaining worklists with recursive descent queries.

Installation and Availability

Install from crates.io: cargo install jsongrep. Like ripgrep (which inspired the project), jsongrep is cross-platform with binaries available and written in Rust.

The tool detects if output is piped to commands like less or sort and omits JSON paths by default (override with --with-path option).

📖 Read the full source: HN LLM Tools

Ad

👀 See Also

AgentTransfer: Open Source Tool Lets OpenClaw Agents Email Files to Each Other
Tools

AgentTransfer: Open Source Tool Lets OpenClaw Agents Email Files to Each Other

AgentTransfer is an open-source single-binary server that gives each AI agent an email address and folder, enabling file sharing between OpenClaw instances via MCP. It supports upload, send, long-poll inbox, and download with SHA256 verification.

OpenClawRadar
Claude AI's UltraThink feature returns with practical usage guidance
Tools

Claude AI's UltraThink feature returns with practical usage guidance

Claude AI has reinstated the UltraThink feature after user feedback. Medium effort is now the default for Opus 4.6 (Max/Team), with High effort available permanently via /model, and UltraThink as a one-turn override to high effort.

OpenClawRadar
Open-source markdown vault gives Claude persistent memory across sessions
Tools

Open-source markdown vault gives Claude persistent memory across sessions

My Portable Brain is a markdown vault structure with an agent runtime layer that provides Claude with persistent context about identity, projects, goals, CRM, and weekly plans. It works natively with Claude Code and Claude Cowork, uses plain markdown files, and runs background scripts nightly to keep context fresh.

OpenClawRadar
Time Complexity MCP: Static Analysis Tool Feeds Big-O Complexity to AI Coding Agents
Tools

Time Complexity MCP: Static Analysis Tool Feeds Big-O Complexity to AI Coding Agents

Time Complexity MCP is an open-source MCP server that performs static code analysis to detect Big-O complexity, feeding the results directly to AI coding agents like Claude Code or Copilot without token consumption. It supports JavaScript, TypeScript, Python, Java, Kotlin, and Dart.

OpenClawRadar