micromatch /picomatch

Blazing fast and accurate glob matcher written JavaScript, with no dependencies and full support for standard and extended Bash glob features, including braces, extglobs, POSIX brackets, and regular expressions. Used by GraphQL, Jest, Astro, Snowpack, Storybook, bulma, Serverless, fdir, Netlify, AWS Amplify, Revogrid, rollup, routify, open-wc, imba, ava, docusaurus, fast-glob, globby, chokidar, anymatch, cloudflare/miniflare, pts, and more than 5 million projects! Please follow picomatch's author: https://github.com/jonschlinkert

★ 1,342⑂ 209👁 13⑃ 178● 90▤ 10
JavaScriptMITCreated 2018-11-05github.com/micromatch
Download: 4.0.74.0.7 ↓4.0.72026-08-24
+1
Daily
+10
Weekly
1,342
stars
209
forks
13
watchers
178
prs
90
issues
10
releases

README

Picomatch




















Blazing fast and accurate glob matcher written in JavaScript.
No dependencies and full support for standard and extended Bash glob features, including braces, extglobs, POSIX brackets, and regular expressions.





 Why picomatch?

 Lightweight - No dependencies
 Minimal - Tiny API surface. Main export is a function that takes a glob pattern and returns a matcher function.
 Fast - Loads in about 2ms (that's several times faster than a single frame of a HD movie at 60fps)
 Performant - Use the returned matcher function to speed up repeat matching (like when watching files)
 Accurate matching - Using wildcards ( and ?), globstars () for nested directories, advanced globbing with extglobs, braces, and POSIX brackets, and support for escaping special characters with \ or quotes.
 Well tested - Thousands of unit tests

See the library comparison to other libraries.




 Table of Contents

 Click to expand 

- Install
- Usage
- API
   picomatch
   .test
   .matchBase
   .isMatch
   .parse
   .scan
   .compileRe
   .makeRe
   .toRegex
- Options
   Picomatch options
   Scan Options
   Options Examples
- Globbing features
   Basic globbing
   Advanced globbing
   Braces
   Matching special characters as literals
- Library Comparisons
- Benchmarks
- Philosophies
- About
   Author
   License

_(TOC generated by verb using markdown-toc)_






 Install

Install with npm:

sh
npm install --save picomatch




 Usage

The main export is a function that takes a glob pattern and an options object and returns a function for matching strings.

js
const pm = require('picomatch');
const isMatch = pm('.js');

console.log(isMatch('abcd')); //= false
console.log(isMatch('a.js')); //= true
console.log(isMatch('a.md')); //= false
console.log(isMatch('a/b.js')); //= false




 API

 picomatch

Creates a matcher function from one or more glob patterns. The returned function takes a string to match as its first argument, and returns true if the string is a match. The returned matcher function also takes a boolean as the second argument that, when true, returns an object with additional information.

Params

 globs {String|Array}: One or more glob patterns.
 options {Object=}
 returns {Function=}: Returns a matcher function.

Example

js
const picomatch = require('picomatch');
// picomatch(glob[, options]);

const isMatch = picomatch('.!(a)');
console.log(isMatch('a.a')); //= false
console.log(isMatch('a.b')); //= true

// For environments without node.js, picomatch/posix provides you a dependency-free matcher, without automatic OS detection.
const picomatch = require('picomatch/posix');
// the same API, defaulting to posix paths
const isMatch = picomatch('a/');
console.log(isMatch('a\\b')); //= false
console.log(isMatch('a/b')); //= true

// you can still configure the matcher function to accept windows paths
const isMatch = picomatch('a/', { options: windows });
console.log(isMatch('a\\b')); //= true
console.log(isMatch('a/b')); //= true


 .te

Top issues

Discussions

Latest release

4.0.7 4.0.7 2026-08-24
What's Changed
 fix: handle terminal globstars in parenthesized patterns by @mrmlnc in https://github.com/micromatch/picomatch/pull/198


Full Changelog: https://github.com/micromatch/picomatch/compare/4.0.6...4.0.7

Snapshot: 2026-11-27T22:26:53Z · Data license Apache-2.0 · JSON