Writing jq Filters With LLMs in October 2026: Paste Real Sample Input, Handle Nulls on Purpose, and Test Before You Pipe
jq is one of those tools almost everyone uses and almost nobody remembers. You need to pull three fields out of an API response, flatten a nested array into CSV, or count records by status, and you end up asking an LLM for the filter. That works well most of the time. The failures are quiet: a filter that returns nothing instead of an error, a default that swallows a real false , or a shell command that breaks the moment a value contains a space. This guide covers how to ask for jq filters so the first answer is usually right, and how to check the ones that aren't. Example JSON code. Image: Dcbmariano , CC BY 4.0 , via Wikimedia Commons . Why LLM-written jq filters go wrong jq looks simple, but its behavior around missing data is subtle, and models tend to write for the happy path. The common problems are: Guessed structure. If you describe your JSON in words instead of pasting it, the model invents field names and nesting. The filter then runs without error and prints null...