A minimal integration between jq and consult for interactive JSON filtering in Emacs.
demo.mp4
This package provides a live-updating interface to filter JSON data in
your current buffer. As you type a jq filter in the minibuffer, the
results are displayed with syntax highlighting. Press RET to copy the
result to the kill ring.
- Emacs 29.1 or newer
- jq
(use-package consult-jq
:straight (:host github :repo "elken/consult-jq")
:commands (consult-jq))- Clone the repository
- Add to your load path
- Require the package
(add-to-list 'load-path "/path/to/consult-jq")
(require 'consult-jq)Open a JSON file and run:
M-x consult-jq
Type a jq filter to see the results update in real-time. Press RET to copy the result to the kill ring.
The package provides several shorthand filters for common operations:
keys- Show all object keysitems- Show keys as separate itemsvalues- Show all valuestypes- Show types of all values
You can customize the available shorthand filters:
(setq consult-jq-filter-alist
'(("items" . "keys[]")
("types" . "map_values(type)")
("count" . "length"))) ;; Added custom shorthand