jqlite is a portable profile of the jq language: jq as a library, defined so that a program gives the same outputs in every language that runs it. It has one specification, one conformance corpus and one engine, written in .NET and ported file by file to TypeScript, Python, Java, Go and Rust.
| Implementation | Package | Guide |
|---|---|---|
| .NET (the reference) | JQLite on NuGet |
jqlite/dotnet |
| TypeScript | @devlooped/jqlite on npm |
jqlite/typescript |
| Python | devlooped-jqlite on PyPI, imported as jqlite |
jqlite/python |
| Java | com.devlooped:jqlite on Maven Central |
jqlite/java |
| Go | module github.com/devlooped/jqlite/go |
jqlite/go |
| Rust | crate jqlite |
jqlite/rust |
To ensure the long-term sustainability of this project, use of jqlite requires an Open Source Maintenance Fee. While the source code is freely available under the terms of the OSMF EULA, all other aspects of the project—including opening or commenting on issues, participating in discussions, and downloading releases—require adherence to the Maintenance Fee.
In short, if you use this project to generate revenue, the Maintenance Fee is required.
To pay the Maintenance Fee, become a Sponsor.
The profile has the jq 1.8 language: paths, pipes, generators, array and object construction,
string interpolation, variables and destructuring (including ?//), def, reduce, foreach,
label/break, try/catch and ?, path expressions and every assignment operator, and modules.
Its builtins cover types and selection, objects, arrays and collections,
paths, strings, formats, dates, math and regular expressions: every builtin of jq 1.8 is in, except
the five that describe jq's command line or read its next input.
jq programs behave as in jq 1.8, except for the differences that make the result exact and equal in every language. Those you are most likely to notice:
- Numbers are doubles, written in one canonical form (
1.0is1;1e-7,1e+21,-0). - Regular expressions use one flavor, common to every implementation, instead of Oniguruma's: no lookaround, backreferences or inline flags, and ASCII character classes.
- A
$namethat the program does not bind is a host variable, given by the caller of the evaluation. - The call depth is limited by an option of the host, and there are no tail calls.
- An evaluation has one input:
inputandinputsare not in the profile.
On the website: the language, a tour, the specification and the jq 1.8 manual.
Every implementation follows the same specification and passes the same corpus, so a program gives the same outputs in each. Values go in and come out as the host's own JSON values where it has ordered ones, and as the engine's values where it does not. The examples below run the same program on the same input.
JQLite is the reference implementation, which the other
engines are ported from. It runs on .NET 8 or later, takes and returns System.Text.Json
JsonElements, and is trimmable and Native AOT compatible.
dotnet add package JQLiteusing System.Text.Json;
using JQLite;
using var people = JsonDocument.Parse(
"""[{"name":"Ada","active":true},{"name":"Lin","active":false}]""");
var results = Jq.Evaluate("[.[] | select(.active) | .name]", people.RootElement);
Console.WriteLine(results[0].GetRawText()); // ["Ada"]The package readme has more examples, the performance against the jq
executable and the upgrade notes from Devlooped.JQSharp 1.x. Read the
.NET guide and the
API reference.
@devlooped/jqlite is an ESM package with no
run-time dependency and its own type declarations, for Node 20 or later and for browsers.
npm install @devlooped/jqliteimport { Jq } from "@devlooped/jqlite";
const people = [{ name: "Ada", active: true }, { name: "Lin", active: false }];
const results = Jq.evaluate("[.[] | select(.active) | .name]", people);
console.log(JSON.stringify(results[0])); // ["Ada"]Read the TypeScript guide, and the port notes to build and test it.
devlooped-jqlite, imported as jqlite, is for
Python 3.11 or later and uses the standard library only. It takes and returns the values of
json.loads.
pip install devlooped-jqliteimport json
import jqlite
people = [{"name": "Ada", "active": True}, {"name": "Lin", "active": False}]
results = jqlite.evaluate("[.[] | select(.active) | .name]", people)
print(json.dumps(results[0])) # ["Ada"]Read the Python guide, and the port notes to build and test it.
com.devlooped:jqlite is for Java 21
or later, with no run-time dependency.
import com.devlooped.jqlite.*;
import com.devlooped.jqlite.values.JqValue;
import java.util.List;
JqValue people = JqJson.parse(
"[{\"name\":\"Ada\",\"active\":true},{\"name\":\"Lin\",\"active\":false}]");
List<JqValue> results = Jq.evaluate("[.[] | select(.active) | .name]", people);
System.out.println(JqJson.toJson(results.get(0))); // ["Ada"]Read the Java guide, and the port notes to build and test it.
The module github.com/devlooped/jqlite/go,
package jqlite, uses the standard library only.
go get github.com/devlooped/jqlite/gopackage main
import (
"fmt"
jqlite "github.com/devlooped/jqlite/go"
)
func main() {
people, _ := jqlite.ParseJSON(`[{"name":"Ada","active":true},{"name":"Lin","active":false}]`)
results, err := jqlite.Evaluate(`[.[] | select(.active) | .name]`, people, nil)
if err != nil {
panic(err)
}
fmt.Println(jqlite.ToJSON(results[0])) // ["Ada"]
}Read the Go guide, and the port notes to build and test it.
The crate jqlite uses edition 2024 and has no unsafe code.
cargo add jqliteuse jqlite::{JqError, JqValue};
fn main() -> Result<(), JqError> {
let people = JqValue::parse(
r#"[{"name":"Ada","active":true},{"name":"Lin","active":false}]"#)?;
let results = jqlite::evaluate("[.[] | select(.active) | .name]", people)?;
println!("{}", results[0].to_json()); // ["Ada"]
Ok(())
}Read the Rust guide, and the port notes to build and test it.
jqlite runs in the process of its host, so it does not pay for starting a process, reading the
program and writing JSON text on every evaluation. The
WhatsApp/Message.jq filter on one WhatsApp message, with
.NET 10 on Windows 11 (BenchmarkDotNet), against the jq executable run through Devlooped.JQ:
| Engine | Mean | Relative to jq |
|---|---|---|
jq executable |
22.15 ms | 1× |
| JQLite, the program parsed on each evaluation | 73.63 µs | 301× faster |
JQLite, the JqExpression parsed once |
6.84 µs | 3,237× faster |
The package readme has the full BenchmarkDotNet output and the programs whose cost must stay linear or lazy.
The cross-language benchmark runs the same 15 cases on
every implementation, checks that each gives the outputs of .expected byte for byte, and divides
its time by the time of .NET: 1.00× is as fast as .NET, 2.00× takes twice as long. Measured with
pwsh bench/run.ps1 on Ubuntu 24.04 in WSL 2, on an AMD Ryzen AI 9 HX 370, with .NET 10.0.15,
Node.js 22.23.5, CPython 3.12.3, OpenJDK 21.0.13, Go 1.26.11 and Rust 1.94.0.
Geometric mean of the 15 cases, for each measurement:
| Measurement | .NET | TypeScript | Python | Java | Go | Rust |
|---|---|---|---|---|---|---|
| Evaluate: a compiled program on a value already read | 1.00× | 1.07× | 9.75× | 0.48× | 1.55× | 0.56× |
| Text to text: read the input, evaluate, write the outputs | 1.00× | 0.78× | 7.72× | 0.36× | 1.21× | 0.42× |
| Compile: parse and bind the program | 1.00× | 1.54× | 19.0× | 0.75× | 1.54× | 1.12× |
Evaluate, for each case (the time of .NET in parentheses):
| Case | .NET | TypeScript | Python | Java | Go | Rust |
|---|---|---|---|---|---|---|
whatsapp |
1.00× (3.44 µs) | 1.51× | 12.5× | 0.59× | 1.35× | 0.66× |
map-add |
1.00× (15.63 ms) | 0.79× | 4.42× | 0.44× | 1.76× | 0.58× |
append-reduce |
1.00× (1.36 ms) | 0.59× | 6.92× | 0.43× | 1.60× | 0.50× |
join-strings |
1.00× (6.86 ms) | 1.11× | 9.30× | 0.61× | 1.36× | 0.89× |
add-strings |
1.00× (2.59 ms) | 0.84× | 6.10× | 0.38× | 1.81× | 0.57× |
update-each |
1.00× (497.56 µs) | 0.61× | 13.1× | 0.42× | 1.82× | 0.74× |
index-reduce |
1.00× (7.40 ms) | 1.08× | 8.22× | 0.26× | 1.81× | 0.51× |
first-of-range |
1.00× (272 ns) | 0.80× | 11.9× | 0.24× | 1.72× | 0.34× |
recursion |
1.00× (6.22 ms) | 0.70× | 15.7× | 0.77× | 0.85× | 0.71× |
group-by |
1.00× (1.67 ms) | 1.39× | 5.56× | 0.73× | 1.52× | 0.54× |
filter-project |
1.00× (2.20 ms) | 1.22× | 10.1× | 0.48× | 1.50× | 0.57× |
strings-regex |
1.00× (8.52 ms) | 2.51× | 21.2× | 0.61× | 1.89× | 0.69× |
paths-walk |
1.00× (11.58 ms) | 1.69× | 16.2× | 0.50× | 1.78× | 0.72× |
json-roundtrip |
1.00× (6.83 ms) | 1.01× | 10.9× | 0.63× | 1.25× | 0.46× |
assign-paths |
1.00× (9.15 ms) | 1.47× | 7.51× | 0.39× | 1.59× | 0.30× |
The behaviour is written down once and tested once, and every implementation runs the same tests. A change goes through the parts in this order: the specification, a case in the corpus, the reference engine, then every port.
| Part | What it is |
|---|---|
spec/jqlite.md |
The language: grammar, values, semantics, builtins, errors, limits, the host interface and the differences from jq. It is normative. |
spec/prelude.jq |
The builtins written in jqlite itself, embedded unchanged by every implementation. |
spec/tests |
The conformance corpus: programs, inputs and the outputs of jq 1.8.2, except where the specification lists a difference. |
dotnet |
The reference engine (dotnet/JQLite/Core), written without anything another language lacks, and the .NET package around it. |
typescript, python, java, go, rust |
The ports, file by file, each with a host API in the idiom of its language. |
bench |
The cross-language benchmark. |
docs |
The website. |
On the website: the project,
the porting guide,
the conformance corpus and
the benchmarks.
AGENTS.md says where each kind of change goes and which rules the engine's code follows.
CI packages are produced from every branch and pull request so you can dogfood builds as quickly as they are produced.
The CI feed is https://pkg.kzu.app/index.json.
The versioning scheme for packages is:
- PR builds: 42.42.42-pr
[NUMBER] - Branch builds: 42.42.42-
[BRANCH].[COMMITS]