Learn about our RFC process, Open RFC meetings & more.Join in the discussion! »


1.0.1 • Public • Published

micromatch NPM version

Glob matching for javascript/node.js. A faster alternative to minimatch (10-20x faster on avg), with all the features you're used to using in your Grunt and gulp tasks.

  • 10-20x faster than [minimatch] on average (see benchmarks)
  • Focus on core Bash 4.3 specification features that are actually used (or can be used) in node.js
  • Supports passing glob patterns as a string or array
  • Extensive unit tests



All the mainstream glob features you're used to using in your gulp and Grunt tasks:

  • Brace Expansion (foo/bar-{1..5}.md, one/{two,three}/four.md)
  • Globstar matching (**/*, a/b/*.js, etc)
  • Logical OR (foo/bar/(abc|xyz).js)
  • Regex character classes (foo/bar/baz-[1-5].js)

You can combine these features to achieve whatever matching patterns you need.

Does not support

  • Extended glob matching. This might be supported in the future, either in core or as an extension, but it's hard to justify the cost in terms of speed and complexity for features that are rarely used.

Install with npm

npm i micromatch --save


Works exactly the same as [minimatch].

var micromatch = require('micromatch');
micromatch(['a.js', 'b.md', 'c.txt'], '*.{js,txt}');
//=> ['a.js', 'c.txt']

Negation patterns:

micromatch(['a.js', 'b.md', 'c.txt'], '!*.{js,txt}');
//=> ['b.md']
micromatch(['a.md', 'b.js', 'c.txt', 'd.json'], ['*.*', '!*.{js,txt}']);
//=> ['a.md', 'd.json']

Special characters

With the exception of brace expansion ({a,b}, {1..5}, etc), most of the special characters convert directly to regex, so you can expect them to follow the same rules and produce the same results as regex.

Square brackets

Given ['a.js', 'b.js', 'c.js', 'd.js', 'E.js']:

  • [ac].js: matches both a and c, returning ['a.js', 'c.js']
  • [b-d].js: matches from b to d, returning ['b.js', 'c.js', 'd.js']
  • [b-d].js: matches from b to d, returning ['b.js', 'c.js', 'd.js']
  • a/[A-Z].js: matches and uppercase letter, returning ['a/E.md']

Learn about regex character classes.


Given ['a.js', 'b.js', 'c.js', 'd.js', 'E.js']:

  • (a|c).js: would match either a or c, returning ['a.js', 'c.js']
  • (b|d).js: would match either b or d, returning ['b.js', 'd.js']
  • (b|[A-Z]).js: would match either b or an uppercase letter, returning ['b.js', 'E.js']

As with regex, parenthese can be nested, so patterns like ((a|b)|c)/b will work. But it might be easier to achieve your goal using brace expansion.

Brace Expansion

In simple cases, brace expansion appears to work the same way as the logical OR operator. For example, (a|b) will achieve the same result as {a,b}.

Here are some powerful features unique to brace expansion (versus character classes):

  • range expansion: a{1..3}b/*.js expands to: ['a1b/*.js', 'a2b/*.js', 'a3b/*.js']
  • nesting: a{c,{d,e}}b/*.js expands to: ['acb/*.js', 'adb/*.js', 'aeb/*.js']

Learn about brace expansion, or visit braces to ask questions and create an issue related to brace-expansion, or to see the full range of features and options related to brace expansion.


Generate a regular expression for matching file paths based on the given pattern:



All options should work the same way as [minimatch].


Match dotfiles.

Type: {Boolean}

Default: false


Allow glob patterns without slashes to match a file path based on its basename.

Type: {Boolean}

Default: false


micromatch(['a/b.js', 'a/c.md'], '*.js');
//=> []
micromatch(['a/b.js', 'a/c.md'], '*.js', {matchBase: true});
//=> ['a/b.js']


Don't expand braces in glob patterns.

Type: {Boolean}

Default: false


Use a case-insensitive regex for matching files.

Type: {Boolean}

Default: false


If true, when no matches are found the actual (array-ified) glob pattern is returned instead of an empty array.

Type: {Boolean}

Default: false


Run the benchmarks

node benchmark/


Run tests

Install dev dependencies

npm i -d && mocha


Pull requests and stars are always welcome. For bugs and feature requests, please create an issue

Please be sure to run the benchmarks before/after any code changes to judge the impact before you do a PR. thanks!


Jon Schlinkert


Copyright (c) 2014-2015, Jon Schlinkert. Released under the MIT license

This file was generated by verb on December 31, 2014.


npm i [email protected]





Last publish


  • avatar
  • avatar
  • avatar