Search 100,000 JSON documents on the GPU

Write the search loop once in JavaScript-style builder code; run it on every document at once on the GPU, with the same answers.

1 The job

You need to search 100,000 JSON documents with a regular expression on every keystroke, and highlight the JSON. In plain JavaScript that is a loop: one document after another, on one thread. On a GPU, you would have to rewrite it all as shaders.

2 Predict

Cheng Lou wrote the matcher and the JSON parser as Handwired programs, then turned them into WebGPU shaders. Against the browser's native, heavily optimized RegExp, how does it do?

3 Poke it

Checking for WebGPU…

Embedded unmodified from chenglou/handwired · src/json-search, MIT license, © 2026 Cheng Lou. Open it full screen. Upstream also runs it on chenglou.me/handwired.

4 Is it the same answer?

The counter you'd want is “0 differences from plain JavaScript”. This page doesn't compute that live; upstream's test suite does, comparing the search programs against plain-JavaScript references over edge cases and fuzzed inputs (tests/json-search: search.test.ts, searcher.test.ts, edge-cases.test.ts, writer-fuzz.ts). The CPU toggle in the demo runs the very same programs as generated JavaScript, so you can flip it and see the same matches.

Reach for Handwired when the same small piece of logic has to run on a huge number of inputs at once, and you want to write it once as readable code instead of hand-writing GPU shaders.

Loading Handwired…