{"id":13582913,"url":"https://github.com/FGRibreau/jq.node","last_synced_at":"2025-04-06T17:32:30.820Z","repository":{"id":45399023,"uuid":"72196002","full_name":"FGRibreau/jq.node","owner":"FGRibreau","description":"jq.node - like jq but WAY MORE powerful (300+ helpers 🔥 \u0026 1.45M modules 😱) ","archived":false,"fork":false,"pushed_at":"2025-02-21T15:56:28.000Z","size":458,"stargazers_count":467,"open_issues_count":4,"forks_count":28,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-04-06T13:01:36.226Z","etag":null,"topics":["javascript-shell","jq"],"latest_commit_sha":null,"homepage":"https://twitter.com/FGRibreau","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/FGRibreau.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE.md","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},"funding":{"github":"fgribreau"}},"created_at":"2016-10-28T09:55:25.000Z","updated_at":"2025-03-17T09:42:53.000Z","dependencies_parsed_at":"2025-03-09T07:36:44.074Z","dependency_job_id":"48f29763-ca7b-4119-b453-34773b8f5368","html_url":"https://github.com/FGRibreau/jq.node","commit_stats":{"total_commits":97,"total_committers":10,"mean_commits":9.7,"dds":"0.21649484536082475","last_synced_commit":"89eb2b7dc3fc94457507e1374e710a062833c3e4"},"previous_names":[],"tags_count":18,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FGRibreau%2Fjq.node","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FGRibreau%2Fjq.node/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FGRibreau%2Fjq.node/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FGRibreau%2Fjq.node/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/FGRibreau","download_url":"https://codeload.github.com/FGRibreau/jq.node/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247485282,"owners_count":20946398,"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","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":["javascript-shell","jq"],"created_at":"2024-08-01T15:03:07.410Z","updated_at":"2025-04-06T17:32:30.786Z","avatar_url":"https://github.com/FGRibreau.png","language":"JavaScript","readme":"### jq.node - Become a shell hero, get super-power\n\n[![Build Status](https://img.shields.io/circleci/project/FGRibreau/jq.node.svg)](https://circleci.com/gh/FGRibreau/jq.node/) ![deps](https://img.shields.io/david/fgribreau/jq.node.svg?style=flat) ![Version](https://img.shields.io/npm/v/jq.node.svg?style=flat) [![Docker hub](https://img.shields.io/docker/pulls/fgribreau/jq.node.svg)](https://hub.docker.com/r/fgribreau/jq.node/) [![available-for-advisory](https://img.shields.io/badge/available%20for%20consulting%20advisory-yes-ff69b4.svg?)](http://bit.ly/2c7uFJq) ![extra](https://img.shields.io/badge/actively%20maintained-yes-ff69b4.svg) [![Twitter Follow](https://img.shields.io/twitter/follow/fgribreau.svg?style=flat)](https://twitter.com/FGRibreau) [![Get help on Codementor](https://cdn.codementor.io/badges/get_help_github.svg)](https://www.codementor.io/francois-guillaume-ribreau?utm_source=github\u0026utm_medium=button\u0026utm_term=francois-guillaume-ribreau\u0026utm_campaign=github) [![Slack](https://img.shields.io/badge/Slack-Join%20our%20tech%20community-17202A?logo=slack)](https://join.slack.com/t/fgribreau/shared_invite/zt-edpjwt2t-Zh39mDUMNQ0QOr9qOj~jrg)\n\njq.node is JavaScript and Lodash in your shell (along with the 1.45M npm modules). It's a powerful command-line JSON/string processor. It so easy it feels like cheating your inner-bearded-sysadmin.\n\n## Rational\n\nI'm a huge fan of [jq](https://github.com/stedolan/jq) **but** it was so many times inconsistent and irritating. It sometimes felt like JavaScript but it was not.\n**jq.node** is what jq should be **in my opinion**. First version was written in 25 lines of JavaScript code and was already way more powerful than jq, backed from day one by more than 300 helpers from Lodash FP.\n\n## Why jq.node? Why not jq?\n\n- jq.node does not try to implement its own expression language, it's pure JavaScript\n- no need to learn new operators or helpers, if you know [lodash/fp](https://github.com/lodash/lodash/wiki/FP-Guide), you know jq.node helpers\n- more powerful than jq **will ever be** `jqn 'filter(has(\"email\")) | groupBy(u =\u003e u.email.split(\"@\")[1]) | csv'`\n- through `--require` command option, jq.node leverages **1.45M npm modules**. Hard to do more powerful than that!\n\n## Why jq? Why not jq.node?\n\n- performance matters more than feature set (in our current implementation jq is faster than jq.node, C vs JavaScript)\n- some features of jq are not currently implemented in jq.node\n- jq is a binary, jq.node is a NodeJS project (🌟 accessible through [a docker image](https://hub.docker.com/r/fgribreau/jq.node/))\n\n## Install (NodeJS)\n\n```\n$ npm install jq.node -g\n\n$ echo '{\"a\": true}' | jqn 'o =\u003e o.a'\ntrue\n```\n\n## Shameless plug\n\n- [Open-Source **Webhook as a Service**](https://www.hook0.com/)\n- [**Charts, simple as a URL**. No more server-side rendering pain, 1 url = 1 chart](https://image-charts.com)\n- [Looking for a free **Redis GUI**?](https://www.redsmin.com) [Or for **real-time alerting** \u0026 monitoring for Redis?](http://redsmin.com)\n- [**Mailpopin**](https://mailpop.in/) - **Stripe** payment emails you can actually use\n\n## CLI Usage\n\n```shell\n# the 4 commands below do the same thing\ncat users.json | jqn 'filter(has(\"email\")) | groupBy(function(u){return u.email.split(\"@\")[1]}) | csv'\ncat users.json | jqn 'filter(has(\"email\")) | groupBy(u =\u003e u.email.split(\"@\")[1]) | csv'\ncat users.json | jqn 'filter(has(\"email\")) | groupBy(u =\u003e get(u.email.split(\"@\"), 1)) | csv'\ncat users.json | jqn 'filter(has(\"email\")) | groupBy(flow(get(\"email\"), split(\"@\"), get(1))) | csv'\n```\n\n- [Complex and tricky JSON querying made easy with jq.node](https://asciinema.org/a/91627)\n- [Editing string (to JSON) in clipboard with jq.node](https://asciinema.org/a/91472)\n\nNote: the pipe ` | ` **must always** be surrounded by space to be understood by `jqn` as a pipe.\n\n### Examples\n\n#### Be notified when a JSON value changed\n\n```\nwhile true; do curl -s http://10.10.0.5:9000/api/ce/task?id=AVhoYB1sNTnExzIJOq_k | jqn 'property(\"task.status\"), thru(a =\u003e exit(a === \"IN_PROGRESS\" ? 0 : 1))' || osascript -e 'display notification \"Task done\"'; sleep 5; done\n```\n\n#### Open every links from the clipboard\n\n```\npbpaste | jqn -x -r opn 'split(\"\\n\") | forEach(opn)'\n```\n\n- pbpaste, echoes clipboard content, MacOS only ([use xclip or xsel in Linux](http://superuser.com/a/288333/215986))\n- [opn](https://github.com/sindresorhus/opn) is \"a better node-open. Opens stuff like websites, files, executables. Cross-platform.\"\n\n\n#### Edit a JSON file\n\nThis command above rely on [tap](https://lodash.com/docs/4.17.15#tap) to add a propety to a [package.json](https://docs.npmjs.com/cli/v6/configuring-npm/package-json) file [[#89](https://github.com/FGRibreau/jq.node/issues/89)]:\n\n```\njq.node 'tap(x =\u003e x.scripts.build= \"sass --load-path=./scss ./scss/style.scss:./css/style.css\")' \u003c package.json\n```\n\n## API Usage\n\n`jq.node` exposes a node API for programmatic use. Require the `jq` function from the main module.\n\nThe arguments are `jq(input, transformation, options, callback)`\n\n```js\nconst { jq } = require('jq.node')\n\njq('20111031', 'thru(a =\u003e moment.utc(a, \"YYYYMMDD\"))', { rawInput: true, require: 'moment' }, function (err, result) {\n  console.log(result) // \"2011-10-31T00:00:00.000Z\"\n})\n```\n\nor with promises and async/await, via the bluebird module:\n\n```js\nconst { Promisify } = require('bluebird')\nconst { jq } = Promisify(require('jq.node'))\n\nconst result = await jq('20111031', 'thru(a =\u003e moment.utc(a, \"YYYYMMDD\"))', { rawInput: true, require: 'moment' })\nconsole.log(result) // \"2011-10-31T00:00:00.000Z\"\n```\n\n## Options\n\n| CLI Shorthand | CLI Longhand | API Option |  Type           | Purpose                                                                                                      |\n| :---          | :---         | :---       | :---:           |                                                                                                         ---: |\n| -h            | --help       | -          | -               | Display the help message and exit.                                                                           |\n| -j            | --json       | json       | boolean         | Force the result to be output as JSON. Without this, `jqn` outputs strings verbatim and non-strings as JSON. |\n| -x            | --raw-input  | rawInput   | boolean         |                                                                                                              |\n| -c            | --color      | color      | boolean         | Colorize JSON (default: detected via chalk/supports-color)                                                   |\n| -r            | --require    | require    | array(string)   | * Require a NPM module `\u003cnpm-module-name\u003e`.                                                                  |\n| -v            | --version    | -          | -               | Display the version and exit.                                                                                |\n\n* jq.node will automatically installs in a temporary folder it if its not available. The module will be available in the expression through its name (e.g. `lodash` for the `lodash` module). Module names that are invalid JavaScript variable names (e.g. `js-yaml`) will be exposed in camel-case format (e.g. `jsYaml`).\n\njq.node uses [chalk/supports-color](https://github.com/chalk/supports-color/tree/main) to detect whether or not to colorize the output. If the `--color` flag is provided, it takes precedence. This detection is disabled for programmatic API usage. For programmatic usage, an explicitly passed option takes precedence over the default (`false`).\n\n## Currently supported\n\n- `templateSettings`, `after`, `ary`, `assign`, `assignIn`, `assignInWith`, `assignWith`, `at`, `before`, `bind`, `bindAll`, `bindKey`, `castArray`, `chain`, `chunk`, `compact`, `concat`, `cond`, `conforms`, `constant`, `countBy`, `create`, `curry`, `curryRight`, `debounce`, `defaults`, `defaultsDeep`, `defer`, `delay`, `difference`, `differenceBy`, `differenceWith`, `drop`, `dropRight`, `dropRightWhile`, `dropWhile`, `fill`, `filter`, `flatMap`, `flatMapDeep`, `flatMapDepth`, `flatten`, `flattenDeep`, `flattenDepth`, `flip`, `flow`, `flowRight`, `fromPairs`, `functions`, `functionsIn`, `groupBy`, `initial`, `intersection`, `intersectionBy`, `intersectionWith`, `invert`, `invertBy`, `invokeMap`, `iteratee`, `keyBy`, `keys`, `keysIn`, `map`, `mapKeys`, `mapValues`, `matches`, `matchesProperty`, `memoize`, `merge`, `mergeWith`, `method`, `methodOf`, `mixin`, `negate`, `nthArg`, `omit`, `omitBy`, `once`, `orderBy`, `over`, `overArgs`, `overEvery`, `overSome`, `partial`, `partialRight`, `partition`, `pick`, `pickBy`, `property`, `propertyOf`, `pull`, `pullAll`, `pullAllBy`, `pullAllWith`, `pullAt`, `range`, `rangeRight`, `rearg`, `reject`, `remove`, `rest`, `reverse`, `sampleSize`, `set`, `setWith`, `shuffle`, `slice`, `sortBy`, `sortedUniq`, `sortedUniqBy`, `split`, `spread`, `tail`, `take`, `takeRight`, `takeRightWhile`, `takeWhile`, `tap`, `throttle`, `thru`, `toArray`, `toPairs`, `toPairsIn`, `toPath`, `toPlainObject`, `transform`, `unary`, `union`, `unionBy`, `unionWith`, `uniq`, `uniqBy`, `uniqWith`, `unset`, `unzip`, `unzipWith`, `update`, `updateWith`, `values`, `valuesIn`, `without`, `words`, `wrap`, `xor`, `xorBy`, `xorWith`, `zip`, `zipObject`, `zipObjectDeep`, `zipWith`, `entries`, `entriesIn`, `extend`, `extendWith`, `add`, `attempt`, `camelCase`, `capitalize`, `ceil`, `clamp`, `clone`, `cloneDeep`, `cloneDeepWith`, `cloneWith`, `conformsTo`, `deburr`, `defaultTo`, `divide`, `endsWith`, `eq`, `escape`, `escapeRegExp`, `every`, `find`, `findIndex`, `findKey`, `findLast`, `findLastIndex`, `findLastKey`, `floor`, `forEach`, `forEachRight`, `forIn`, `forInRight`, `forOwn`, `forOwnRight`, `get`, `gt`, `gte`, `has`, `hasIn`, `head`, `identity`, `includes`, `indexOf`, `inRange`, `invoke`, `isArguments`, `isArray`, `isArrayBuffer`, `isArrayLike`, `isArrayLikeObject`, `isBoolean`, `isBuffer`, `isDate`, `isElement`, `isEmpty`, `isEqual`, `isEqualWith`, `isError`, `isFinite`, `isFunction`, `isInteger`, `isLength`, `isMap`, `isMatch`, `isMatchWith`, `isNaN`, `isNative`, `isNil`, `isNull`, `isNumber`, `isObject`, `isObjectLike`, `isPlainObject`, `isRegExp`, `isSafeInteger`, `isSet`, `isString`, `isSymbol`, `isTypedArray`, `isUndefined`, `isWeakMap`, `isWeakSet`, `join`, `kebabCase`, `last`, `lastIndexOf`, `lowerCase`, `lowerFirst`, `lt`, `lte`, `max`, `maxBy`, `mean`, `meanBy`, `min`, `minBy`, `stubArray`, `stubFalse`, `stubObject`, `stubString`, `stubTrue`, `multiply`, `nth`, `noConflict`, `noop`, `now`, `pad`, `padEnd`, `padStart`, `parseInt`, `random`, `reduce`, `reduceRight`, `repeat`, `replace`, `result`, `round`, `runInContext`, `sample`, `size`, `snakeCase`, `some`, `sortedIndex`, `sortedIndexBy`, `sortedIndexOf`, `sortedLastIndex`, `sortedLastIndexBy`, `sortedLastIndexOf`, `startCase`, `startsWith`, `subtract`, `sum`, `sumBy`, `template`, `times`, `toFinite`, `toInteger`, `toLength`, `toLower`, `toNumber`, `toSafeInteger`, `toString`, `toUpper`, `trim`, `trimEnd`, `trimStart`, `truncate`, `unescape`, `uniqueId`, `upperCase`, `upperFirst`, `each`, `eachRight`, `first` are exposed from [lodash/fp](https://github.com/lodash/lodash/wiki/FP-Guide).\n- `csv` is exposed from [json2csv](https://github.com/zemirco/json2csv)\n- any of 300 000+ [npm modules](https://www.npmjs.com/) through the `--require` option!\n\n\n## Performance\n\n- jq      `time sh -c \"cat messages.json | jq '.[].type'\"`              `2ms user 0.01s system 95% cpu 0.028 total`\n- jq.node `time sh -c \"cat messages.json | jqn 'map(\\\"type\\\")'\"`         `170ms user 0.03s system 108% cpu 0.181 total`\n\n## Roadmap\n\n- [x] Tests\n- [ ] Json-stream support\n- [x] Optionally colorize output (while still JSON compatible)\n\nI accept pull-requests!\n\n## [Changelog](/CHANGELOG.md)\n\n\n\u003c!-- BACKERS/ --\u003e\n\n\u003ch2\u003eBackers\u003c/h2\u003e\n\n\u003ch3\u003eMaintainers\u003c/h3\u003e\n\nNo maintainers yet! Will you be the first?\n\n\u003ch3\u003eSponsors\u003c/h3\u003e\n\nNo sponsors yet! Will you be the first?\n\n\u003cspan class=\"badge-patreon\"\u003e\u003ca href=\"https://patreon.com/fgribreau\" title=\"Donate to this project using Patreon\"\u003e\u003cimg src=\"https://img.shields.io/badge/patreon-donate-yellow.svg\" alt=\"Patreon donate button\" /\u003e\u003c/a\u003e\u003c/span\u003e\n\u003cspan class=\"badge-gratipay\"\u003e\u003ca href=\"https://gratipay.com/fgribreau\" title=\"Donate weekly to this project using Gratipay\"\u003e\u003cimg src=\"https://img.shields.io/badge/gratipay-donate-yellow.svg\" alt=\"Gratipay donate button\" /\u003e\u003c/a\u003e\u003c/span\u003e\n\u003cspan class=\"badge-flattr\"\u003e\u003ca href=\"https://flattr.com/profile/fgribreau\" title=\"Donate to this project using Flattr\"\u003e\u003cimg src=\"https://img.shields.io/badge/flattr-donate-yellow.svg\" alt=\"Flattr donate button\" /\u003e\u003c/a\u003e\u003c/span\u003e\n\u003cspan class=\"badge-paypal\"\u003e\u003ca href=\"https://fgribreau.me/paypal\" title=\"Donate to this project using Paypal\"\u003e\u003cimg src=\"https://img.shields.io/badge/paypal-donate-yellow.svg\" alt=\"PayPal donate button\" /\u003e\u003c/a\u003e\u003c/span\u003e\n\u003cspan class=\"badge-bitcoin\"\u003e\u003ca href=\"https://www.coinbase.com/fgribreau\" title=\"Donate to this project using Cryptocurrency\"\u003e\u003cimg src=\"https://img.shields.io/badge/crypto-donate-yellow.svg\" alt=\"crypto donate button\" /\u003e\u003c/a\u003e\u003c/span\u003e\n\n\u003ch3\u003eContributors\u003c/h3\u003e\n\nThese amazing people have contributed code to this project:\n\n\u003cul\u003e\u003cli\u003e\u003ca href=\"http://bit.ly/2c7uFJq\"\u003eFrancois-Guillaume Ribreau\u003c/a\u003e\u003c/li\u003e\n\u003cli\u003e\u003ca href=\"https://github.com/chocolateboy\"\u003echocolateboy\u003c/a\u003e — \u003ca href=\"https://github.com/fgribreau/jq.node/commits?author=chocolateboy\" title=\"View the GitHub contributions of chocolateboy on repository fgribreau/jq.node\"\u003eview contributions\u003c/a\u003e\u003c/li\u003e\n\u003cli\u003e\u003ca href=\"https://github.com/bronislav\"\u003eAnton Ilin\u003c/a\u003e — \u003ca href=\"https://github.com/fgribreau/jq.node/commits?author=bronislav\" title=\"View the GitHub contributions of Anton Ilin on repository fgribreau/jq.node\"\u003eview contributions\u003c/a\u003e\u003c/li\u003e\n\u003cli\u003e\u003ca href=\"http://delapouite.com\"\u003eBruno Heridet\u003c/a\u003e\u003c/li\u003e\n\u003cli\u003e\u003ca href=\"https://github.com/thalesmello\"\u003eThales Mello\u003c/a\u003e — \u003ca href=\"https://github.com/fgribreau/jq.node/commits?author=thalesmello\" title=\"View the GitHub contributions of Thales Mello on repository fgribreau/jq.node\"\u003eview contributions\u003c/a\u003e\u003c/li\u003e\n\u003cli\u003e\u003ca href=\"http://michael.mior.ca\"\u003eMichael Mior\u003c/a\u003e\u003c/li\u003e\u003c/ul\u003e\n\n\u003ca href=\"https://github.com/fgribreau/jq.node/blob/master/CONTRIBUTING.md#files\"\u003eDiscover how you can contribute by heading on over to the \u003ccode\u003eCONTRIBUTING.md\u003c/code\u003e file.\u003c/a\u003e\n\n\u003c!-- /BACKERS --\u003e\n\n\n\u003c!-- LICENSE/ --\u003e\n\n\u003ch2\u003eLicense\u003c/h2\u003e\n\nUnless stated otherwise all works are:\n\n\u003cul\u003e\u003cli\u003eCopyright \u0026copy; \u003ca href=\"http://fgribreau.com/\"\u003eFrancois-Guillaume Ribreau\u003c/a\u003e\u003c/li\u003e\u003c/ul\u003e\n\nand licensed under:\n\n\u003cul\u003e\u003cli\u003e\u003ca href=\"http://spdx.org/licenses/MIT.html\"\u003eMIT License\u003c/a\u003e\u003c/li\u003e\u003c/ul\u003e\n\n\u003c!-- /LICENSE --\u003e\n","funding_links":["https://github.com/sponsors/fgribreau","https://patreon.com/fgribreau"],"categories":["JavaScript","others","Tools and Plugins"],"sub_categories":["Windows"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FFGRibreau%2Fjq.node","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FFGRibreau%2Fjq.node","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FFGRibreau%2Fjq.node/lists"}