Skip to content
A CSS selector parser, integrates with postcss but does not require it.
Branch: master
Clone or download
Type Name Latest commit message Commit time
Failed to load latest commit information.
src test: new pseudo classes (#193) Mar 16, 2019
.babelrc 6.0.0 Feb 25, 2019
.gitignore Removed the dot-prop dependency Mar 7, 2018
.travis.yml chore: remove outdated integration tests Oct 24, 2018
LICENSE-MIT README, licence, etc. May 29, 2015
postcss-selector-parser.d.ts API for getting the node at specific source location. May 4, 2018

postcss-selector-parser Build Status

Selector parser with built in methods for working with selector strings.


With npm do:

npm install postcss-selector-parser

Quick Start

const parser = require('postcss-selector-parser');
const transform = selectors => {
    selectors.walk(selector => {
        // do something with the selector

const transformed = parser(transform).processSync('h1, h2, h3');

To normalize selector whitespace:

const parser = require('postcss-selector-parser');
const normalized = parser().processSync('h1, h2, h3', {lossless: false});
// -> h1,h2,h3

Async support is provided through parser.process and will resolve a Promise with the resulting selector string.


Please see


  • Huge thanks to Andrey Sitnik (@ai) for work on PostCSS which helped accelerate this module's development.



You can’t perform that action at this time.