GitHub - kanso-lang/kq: jq-style JSON queries, byte-identical to jq -S and faster on paths — written in kanso · GitHub
/" data-turbo-transient="true" />
Skip to content
Search or jump to...
Search code, repositories, users, issues, pull requests...
-->
Search
Clear
Search syntax tips
Provide feedback
--><br>We read every piece of feedback, and take your input very seriously.
Include my email address so I can be contacted
Cancel
Submit feedback
Saved searches
Use saved searches to filter your results more quickly
-->
Name
Query
To see all available qualifiers, see our documentation.
Cancel
Create saved search
Sign in
/;ref_cta:Sign up;ref_loc:header logged out"}"<br>Sign up
Appearance settings
Resetting focus
You signed in with another tab or window. Reload to refresh your session.<br>You signed out in another tab or window. Reload to refresh your session.<br>You switched accounts on another tab or window. Reload to refresh your session.
Dismiss alert
{{ message }}
Uh oh!
There was an error while loading. Please reload this page.
kanso-lang
kq
Public
Notifications<br>You must be signed in to change notification settings
Fork
Star
main
BranchesTags
Go to file
CodeOpen more actions menu
Folders and files<br>NameNameLast commit message<br>Last commit date<br>Latest commit
History<br>5 Commits<br>5 Commits
.github/workflows
.github/workflows
fixtures
fixtures
.gitignore
.gitignore
LICENSE
LICENSE
README.md
README.md
TRY.md
TRY.md
json.kso
json.kso
kq_test.kso
kq_test.kso
main.kso
main.kso
number.kso
number.kso
path.kso
path.kso
pretty.kso
pretty.kso
scan.kso
scan.kso
spec.sh
spec.sh
text.kso
text.kso
value.kso
value.kso
View all files
Repository files navigation
kq
A jq-style JSON query tool, written in kanso. Output<br>is byte-identical to jq -S on every query below — verified with diff, not<br>claimed.
Speed
Interleaved runs, best-of-25, whole-process wall time (startup + read + parse +<br>query + print), Apple M-series. Reproduce: sh bench/kq_race.sh.
workload<br>kq<br>jq 1.7.1
path query, 188 KB (.[0].k0_30)<br>3.2 ms<br>4.8 ms<br>kq 1.49x faster, 25/25 runs
path query, 1.9 MB (.[0].k0_30)<br>15.5 ms<br>25.0 ms<br>kq 1.61x faster, 15/15 runs
full pretty-print, 188 KB (.)<br>12.0 ms<br>12.8 ms<br>kq 1.07x faster, 24/25 runs
full pretty-print, 1.9 MB<br>109 ms<br>106 ms<br>jq 1.03x faster
The path-query gap grows with document size: kq decodes, walks to the subtree,<br>and prints only that — the win compounds as the part you didn't ask for gets<br>bigger. Full-document dumps are printer-bound, where the two are at parity;<br>kq's pretty-printer is the next optimization target on the ledger.
One deliberate difference: on a path that doesn't exist, jq prints<br>null; kq reports an error naming the missing key. kanso treats a missing<br>index as a failure to surface, not a nothing to pass along — if you want<br>jq's silence, query a path that exists. The race harness verifies<br>byte-identity per query before timing anything, which is exactly how this<br>difference was caught.
Use
[file.json] # or pipe json on stdin<br>kq .users[3].name data.json">kq [file.json] # or pipe json on stdin<br>kq .users[3].name data.json
Why it's fast
kq is ~400 lines of kanso sharing its decoder with the standard library — the<br>same decoder that outruns hand-tuned serde_json on the language's json<br>gauntlet. No hand-written parser tricks live in this directory; the speed is<br>the compiler's. The story: kanso-lang.dev/compiler.html.
Specs
sh spec.sh (with KANSO pointing at a kanso build) runs the unit tests,<br>then eleven fixture cases over non-trivial JSON — unicode/CJK/emoji and<br>escapes, precision-edge numbers, deep nesting and empty containers, and the<br>188 KB nested document — each checked against a committed golden AND against<br>live jq -S byte-for-byte. CI gates on all of it.
Intel macs: no GitHub runners exist for that target anymore; build from<br>source (kanso build .) or use Rosetta until a cross-build lands.
About
jq-style JSON queries, byte-identical to jq -S and faster on paths — written in kanso
Resources
Readme
License
MIT license
Uh oh!
There was an error while loading. Please reload this page.
Activity
Custom properties
Stars
star
Watchers
watching
Forks
forks
Report repository
Releases
kq v0.1.0
Latest
Jul 19, 2026
Packages
Uh oh!
There was an error while loading. Please reload this page.
Contributors
Uh oh!
There was an error while loading. Please reload this page.
Languages
Shell<br>100.0%
You can’t perform that action at this time.