{"id":30237942,"url":"https://github.com/stainless-api/jq-web","last_synced_at":"2025-10-04T01:54:51.588Z","repository":{"id":304652910,"uuid":"1019454912","full_name":"stainless-api/jq-web","owner":"stainless-api","description":"Emscripten-compiled jq that is compatible with cloudflare workers","archived":false,"fork":false,"pushed_at":"2025-08-11T21:28:54.000Z","size":6806,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-10-01T00:42:01.140Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/stainless-api.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-07-14T10:54:22.000Z","updated_at":"2025-08-11T18:48:59.000Z","dependencies_parsed_at":"2025-07-14T14:54:39.335Z","dependency_job_id":"d174be95-50f0-4e7d-8abc-9464ae6198d1","html_url":"https://github.com/stainless-api/jq-web","commit_stats":null,"previous_names":["stainless-api/jq-web"],"tags_count":8,"template":false,"template_full_name":null,"purl":"pkg:github/stainless-api/jq-web","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stainless-api%2Fjq-web","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stainless-api%2Fjq-web/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stainless-api%2Fjq-web/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stainless-api%2Fjq-web/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/stainless-api","download_url":"https://codeload.github.com/stainless-api/jq-web/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stainless-api%2Fjq-web/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278254460,"owners_count":25956599,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-03T02:00:06.070Z","response_time":53,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-08-15T02:58:00.187Z","updated_at":"2025-10-04T01:54:51.572Z","avatar_url":"https://github.com/stainless-api.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![npm badge](https://img.shields.io/npm/v/jq-web.svg)](https://www.npmjs.com/package/jq-web) [![Mentioned in Awesome jq](https://awesome.re/mentioned-badge.svg)](https://github.com/fiatjaf/awesome-jq)\n\n# jq-web (Cloudflare Workers Compatible Fork)\n\nThis is a fork of [jq-web](https://github.com/fiatjaf/jq-web) that is compatible with Cloudflare Workers and other JavaScript environments.\n\nThis is a WebAssembly build of [jq](https://github.com/jqlang/jq), the command-line JSON processor.\n\nIt runs in the browser, Node.js, and Cloudflare Workers.\n\n## Why use this fork?\n\n**Use this fork if you:**\n- Need to run jq in Cloudflare Workers\n- Want a simple, consistent API across all environments\n- Prefer static bundling over dynamic WASM loading\n- Are building libraries that need universal compatibility\n\n**Use the original jq-web if you:**\n- Only target browsers/Node.js (not Cloudflare Workers)\n- Want smaller bundle sizes (dynamic WASM loading)\n- Need the most memory-efficient option for Node.js servers\n\n## Key differences from original jq-web\n\n1. **Static WASM bundling** - The WASM file is imported at build time rather than fetched at runtime\n2. **Universal compatibility** - Works in Cloudflare Workers, which doesn't support dynamic WASM fetching\n3. **Emscripten web mode** - Built with `ENVIRONMENT=\"web\"` for better compatibility\n4. **Simplified API** - One import works everywhere, no environment detection needed\n\n## Installation and use\n\n```bash\nnpm install jq-web\n```\n\n```js\nimport initJq from 'jq-web';\n\nconst jq = await initJq();\nconst output = jq.json({\n  a: {\n    big: {\n      json: [\n        'full',\n        'of',\n        'important',\n        'things'\n      ]\n    }\n  }\n}, '.a.big.json | [\"empty\", .[1], \"useless\", .[3]] | join(\" \")');\n```\n\nThe code above returns the string `\"empty of useless things\"`.\n\n### Webpack issues\n\n#### `fs`\nThe Emscripten runtime will try to `require` the `fs` module, and if it fails it will resort to an in-memory filesystem (almost no use of that is made of the library, but it is needed somehow). In Browserify there's a default `{}` that corresponds to the `fs` module, but in Webpack you must [declare it as an empty module](https://github.com/fiatjaf/jq-web/issues/5#issuecomment-342694955).\n\n#### 404 error when loading `.wasm` files\nBy default projects compiled with Emscripten look for `.wasm` files in the same directory that the `.js` file is run from. This causes issues when using webpack because name of the `.wasm` file is altered with a hash and can be placed in a different directory. To fix this problem you can use the [copy-webpack-plugin](https://github.com/webpack-contrib/copy-webpack-plugin) to copy the `jq.wasm` file to the same directory that the webpack bundle is placed.\n\n## Reference\n\n`jq-web` exports a promise that resolves to an object with `json` and `raw` methods.\n\n`jq.json(\u003cobject\u003e, \u003cfilter\u003e) \u003cobject\u003e` will take a Javascript object, or scalar, whatever, and dump it to JSON, then it will return whatever your filter outputs and try to convert that into a JS object.\n\n`jq.raw(\u003cjson-string\u003e, \u003cfilter\u003e, \u003cflags\u003e) \u003craw-output\u003e` will take a string that will be passed as it is to jq (like if you were doing `echo '\u003cjson-string\u003e' | jq \u003cfilter\u003e` on the command line) then return a string with the raw STDOUT response.\n\n## Build\n\n### Option 1: Using Docker (Recommended)\n```bash\n./docker-make.sh          # Builds everything (equivalent to 'make all')\n./docker-make.sh clean    # Cleans build artifacts\n./docker-make.sh test     # Runs tests\n```\n\n### Option 2: Local Build\n1. Install Emscripten. There have been several API changes over time; version 3.1.31\nis known to work.\n2. Clone this repository, and `cd` into it.\n3. `make`\n    * This may take a while if you have never run Emscripten before.\n\n## Test\nA handful of tests exist in `test.js`. These are a good place to start when verifying a build.\nTo run them, do `make test`.\n\nYou can test browser functionality by running:\n`./node_modules/live-server/live-server.js --open=\"index.html\"`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstainless-api%2Fjq-web","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstainless-api%2Fjq-web","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstainless-api%2Fjq-web/lists"}