Skip to content

Specification Overview

The JSONQL spec defines the query grammar, adapters, and compliance expectations to ensure interoperability across all supported SDKs and databases.

JSONQL is a secure, lightweight, and polyglot JSON-based query language for filtering, sorting, pagination, and field selection.

It is designed to be:

  • Framework-agnostic (Express, Fastify, NestJS, Gin, Echo, net/http, Spring Boot, Jakarta EE, Flask, FastAPI, Django)
  • Database-agnostic (PostgreSQL, MySQL, SQLite, MSSQL, and MongoDB)
  • Secure by design (parameterized, no eval, no regex execution)
VersionStatusDescription
v1.0StableCore query language: field selection, filtering, sorting, pagination, eager loading.
v1.1DraftAggregations, groupBy, distinct, advanced include with sub-queries.
{
"version": "1.0",
"fields": ["id", "name", "email"],
"where": {
"status": { "eq": "active" },
"age": { "gte": 18 }
},
"sort": ["-created_at", "name"],
"limit": 50,
"skip": 0,
"include": ["posts", "profile"]
}
KeyTypeRequiredDescription
versionstringYesMust be "1.0"
fieldsstring[]NoField projection
whereobjectNoFilter conditions
sortstring | string[]NoPrefix - for descending
limitintegerNoMax results (recommended max: 1000)
skipintegerNoOffset for pagination
includestring[]NoEager load related resources
{
"version": "1.1",
"include": {
"posts": {
"fields": ["title", "slug"],
"where": { "published": { "eq": true } },
"sort": "-created_at",
"limit": 5
}
},
"aggregate": {
"total": { "count": "id" },
"avg_age": { "avg": "age" }
},
"groupBy": ["role"],
"distinct": true
}
KeyTypeDescription
includeobjectSub-queries on relationships (where, sort, limit, fields)
aggregateobjectAggregation functions: count, sum, avg, min, max
groupBystring[]Group results by fields
distinctboolean | string[]Select unique values
OperatorExampleSQL
eq{"status": {"eq": "active"}}= ?
ne{"status": {"ne": "banned"}}!= ?
gt{"age": {"gt": 18}}> ?
gte{"age": {"gte": 21}}>= ?
lt{"score": {"lt": 50}}< ?
lte{"score": {"lte": 100}}<= ?
OperatorExampleSQL
in{"id": {"in": [1, 2, 3]}}IN (?, ?, ?)
nin{"role": {"nin": ["admin"]}}NOT IN (?)
OperatorExampleSQL
contains{"name": {"contains": "john"}}LIKE '%john%'
starts{"name": {"starts": "J"}}LIKE 'J%'
ends{"email": {"ends": ".com"}}LIKE '%.com'
{
"where": {
"and": [
{ "age": { "gte": 18 } },
{ "or": [
{ "role": { "eq": "admin" } },
{ "email": { "ends": "@company.com" } }
]}
]
}
}

Compare a field against another field rather than a literal value:

{
"where": {
"salePrice": { "gt": { "field": "basePrice" } }
}
}

Schemas define per-table and per-field permissions to restrict what clients can query:

PermissionDescription
allowSelectFields that can be selected
allowFilterFields that can be filtered
allowSortFields that can be sorted
allowIncludeRelations that can be included
allowAggregateWhether aggregation is allowed
allowCount / allowSum / allowAvg / allowMin / allowMaxGranular aggregate function control

The spec includes a JSON Schema (draft 2020-12) for validating both v1.0 and v1.1 queries programmatically.

The JSONQL ecosystem uses a comprehensive compliance test suite to verify that every SDK and adapter combination produces correct behavior. See the Compliance Testing page for the test matrix and configuration reference, and the Integration Testing guide for details on building adapter servers and running tests.