Skip to content

query-string

6,904 2 2 MIT
9.3.1 (18 Sep 2025) Nov 13 2013 79.7 million (month)

The query-string library is a Node.js library that provides a simple way to parse and stringify query strings. It is useful for working with the query string portion of a URL, which is the part of the URL that follows 'the "?" character and contains key-value pairs.

Example Use


```javascript import queryString from 'query-string';

console.log(location.search); //=> '?foo=bar'

const parsed = queryString.parse(location.search); console.log(parsed); //=> {foo: 'bar'}

console.log(location.hash); //=> '#token=bada55cafe'

const parsedHash = queryString.parse(location.hash); console.log(parsedHash); //=> {token: 'bada55cafe'}

parsed.foo = 'unicorn'; parsed.ilike = 'pizza';

const stringified = queryString.stringify(parsed); //=> 'foo=unicorn&ilike=pizza'

location.search = stringified; // note that location.search automatically prepends a question mark console.log(location.search); //=> '?foo=unicorn&ilike=pizza' ```

Alternatives / Similar


605 10.1.0 (2025-11-08 19:50:46 ago) May 05 2015 compare
ip
1,545 2.0.1 (2025-10-13 17:09:54 ago) Aug 15 2012 compare
6,236 0.1.3 (2022-06-28 06:09:19 ago) Jun 18 2013 compare

Other Languages

1,316 0.7.1 (2025-10-10 03:54:20 ago) Dec 28 2012 compare
1,486 1.3.1 (2026-03-04 18:05:49 ago) Feb 14 2011 compare
url
109 v2.2.0 (2026-01-06 19:06:56 ago) Apr 15 2018 compare
Was this page helpful?