Faster, simpler and more portable implementation of jq-inspired language in OCaml
  • OCaml 94%
  • Perl 1.8%
  • JavaScript 1.3%
  • Shell 1.1%
  • Makefile 1%
  • Other 0.7%
Find a file
2026-07-29 21:35:38 +00:00
.cursor refactor: update REPL to textarea and new Mosaic API 2026-02-23 23:57:44 +00:00
.githooks Make prepush execccc 2025-04-23 15:28:32 +02:00
.github Update OCaml and MLX toolchain 2026-07-29 21:35:38 +00:00
benchmarks Add bench_gc_pressure 2026-05-07 15:11:33 +00:00
cli Update OCaml and MLX toolchain 2026-07-29 21:35:38 +00:00
docs Add demos into queryjson 2026-03-11 15:41:05 +00:00
js Run formatter with different config 2026-03-09 19:09:30 +00:00
scripts Implement many missing features 2025-11-10 19:55:07 +01:00
source Fix decimal operations 2026-03-18 11:43:41 +00:00
website Update OCaml and MLX toolchain 2026-07-29 21:35:38 +00:00
.gitattributes Try to make CI faster (#67) 2026-01-16 17:37:49 +01:00
.gitignore fix init script, update readme 2025-04-30 12:30:01 +00:00
.node-version Remove all languages from monaco editor 2025-11-24 17:14:31 +01:00
.npmignore Cleanup stuff 2025-04-22 19:32:46 +02:00
.ocamlformat Update OCaml and MLX toolchain 2026-07-29 21:35:38 +00:00
CHANGES.md docs: move unreleased entries into 1.0.0~beta-1, add changelog for recent fixes 2026-03-09 19:24:48 +00:00
dune-project Update OCaml and MLX toolchain 2026-07-29 21:35:38 +00:00
index.html Add a few useCallbacks and useMemoitos 2025-11-20 17:32:37 +01:00
LICENSE docs: Add a LICENCE 2020-09-10 14:05:28 +02:00
Makefile Update OCaml and MLX toolchain 2026-07-29 21:35:38 +00:00
package-lock.json Remove all languages from monaco editor 2025-11-24 17:14:31 +01:00
package.json Remove all languages from monaco editor 2025-11-24 17:14:31 +01:00
query-json-js.opam New repl, new help, new language (aka v1.0.0~beta) (#58) 2026-01-10 10:55:37 +01:00
query-json-playground.opam Update OCaml and MLX toolchain 2026-07-29 21:35:38 +00:00
query-json.opam Update OCaml and MLX toolchain 2026-07-29 21:35:38 +00:00
query-json.opam.template Onyl avaiable on native compiler 2025-11-16 15:13:23 +01:00
README.md Fixes install script link (#69) 2026-04-28 10:39:52 +02:00



query-json logo query-json logo

A fast, friendly and portable JSON query language for the command line.

query-json lets you slice, filter, and transform JSON data with a concise, expressive syntax. It started as a jq-compatible implementation, but evolved into something better: faster execution, better error messages, and a modernized language design.

Why?

Fast

Native binary compiled with OCaml. Consistently 2-4x faster than jq across file sizes and operations.

File Size Speed vs jq
< 10KB 2.4-3x faster
100-500KB 2-4.5x faster
> 500KB 1.6-3.3x faster

See detailed benchmarks

Easier to Learn

Designed to be learnable without leaving your terminal:

  • Interactive REPL with context-aware autocomplete—type . to see keys, | to see functions
  • Helpful error messages that tell you why something failed and how to fix it
  • Built-in function reference: query-json --functions lists all functions by category
$ query-json ".naem" <<< '{"name": "Alice", "age": 30}'
error[key_not_found]: key `naem` not found
  --> .naem
      ^^^^

  in: {"name": "Alice", "age": 30}
  available keys: name, age
  hint: use `.naem?` for optional access

Compare to jq

$ jq ".naem" <<< '{"name": "Alice", "age": 30}'
null
query-json interactive REPL demo

Portable

Written in OCaml, it compiles to both native code and JavaScript. Use the same query language:

  • As a CLI tool on macOS, Linux, and Windows
  • In the browser via our online playground
  • As a Node.js library: npm install @davesnx/query-json

jq, but better

We love jq's core ideas, but most of their design is arcane and forced the be backwards compatible. We looked into it with fresh eyes and came up with some improvements:

The old jq names still work but show deprecation warnings. See the full jq Compatibility Guide for details.

Installation

Using the install script

Check the content of scripts/install.sh before running anything in your local. Friends don't let friends curl | bash.

curl -sfL https://query-json.pages.dev/install.sh | bash

Using npm

npm install --global @davesnx/query-json

Download from GitHub

Pre-built binaries for macOS, Linux, and Windows are available on the releases page.

Quick Start

Query a file

query-json '.store.books[0].title' bookstore.json

Query from stdin

curl -s https://api.github.com/users/ocaml | query-json '{name: .name, description: .bio, img: .avatar_url}'

Query inline JSON

query-json '.users | length' '{"users": [1, 2, 3]}'

Common operations

# Get all keys from an object
query-json 'keys' config.json

# Filter array elements
query-json '.items | map(select(.price > 100))' products.json

# Transform data
query-json '.users | map({name, email})' users.json

# Group and count
query-json 'group_by(.category) | map_values(length)' items.json

# String operations
query-json '.title | to_lowercase | split(" ") | first' article.json

Documentation

CLI Options

query-json [OPTIONS] <QUERY> [FILE]

Arguments:
  <QUERY>    The query to run
  [FILE]     JSON file to query (reads from stdin if omitted)

Options:
  -r, --raw-output    Output strings without quotes
  --no-color          Disable colored output
  --repl              Start interactive REPL mode
  -v, --verbose       Show verbose output including deprecation warnings
  --debug             Print lexer tokens and AST
  --version           Print version
  --help              Print help

Contributing

Contributions are welcome! See the development setup below to get started.

Development

Requirements: opam

git clone https://github.com/davesnx/query-json
cd query-json
make init       # Create opam switch and install dependencies
make dev-core   # Build query-json
make test       # Run tests

Running the playground locally

# Terminal 1: Build and watch
make dev

# Terminal 2: Start web server
make web-dev

Support

License

MIT