node package manager
Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org »



miniquery allows you to query objects for a given path and returns you an Array of values matching.

NPM version Build status Dependency Status devDependency Status Coverage Status Code Climate


First install miniquery in you project:

npm install --save miniquery

Getting started

Then, use it:

var miniquery = require('miniquery');
var assert = require('assert');
var fruits = [{
  name: 'orange'
  count: 2,
  colors: ['orange']
}, {
    name: 'banana',
  count: 0,
  colors: ['yellow', 'white']
}, {
    name: 'kiwi',
  count: 8,
  colors: ['brown', 'green']
var orangeColor = miniquery('0.colors.0', [fruits]);
assert.deepEqual(orangeColor, ['orange']);
var counts = miniquery('*.count', [fruits]);
assert.deepEqual(counts, [2, 0, 8]);
var colors = miniquery('colors.#', fruits);
assert.deepEqual(colors, ['orange', 'yellow', 'white', 'brown', 'green']);

Note that miniquery always returns an Array even if there is no or only one result.

CLI usage

Install miniquery globally:

sudo npm install -g miniquery

Then, simply run your queries on one or more JSON files. Let's assume we want to list distinct keywords on all of our NodeJS projects :

miniquery "keywords.*" ~/projects/*/package.json -p | uniq
# minimatch 
# gulp 
# svg 
# gulp 
# gulp-plugin 
# (...) 
# github 
# server 
# web 

Get every available options by running:

miniquery -h
# Usage: miniquery [options] <query> <file ...> 
# Options: 
#   -h, --help       output usage information 
#   -V, --version    output the version number 
#   -v, --verbose    tell me everything! 
#   -j, --json       output JSON 
#   -p, --primitive  print primitives only 


values:Array miniquery(path:String, objs:Array)

Return the values matching the given path for the objects contained in objs.


Feel free to submit us your improvements. To do so, you must accept to publish your code under the MIT license.

To start contributing, first run the following to setup the development environment:

git clone
cd miniquery
npm install

Then, run the tests:

npm test