<commit_before># query-string [![Build Status](https://travis-ci.org/sindresorhus/query-string.svg?branch=master)](https://travis-ci.org/sindresorhus/query-string)

> Parse and stringify URL [query strings](http://en.wikipedia.org/wiki/Query_string)


## Install

```sh
$ npm install --save query-string
```

```sh
$ bower install --save query-string
```

```sh
$ component install sindresorhus/query-string
```


## Usage

```js
console.log(location.search);
// ?foo=bar

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

console.log(location.hash);
// #token=<PASSWORD>

var parsedHash = queryString.parse(location.hash);
console.log(parsedHash);
// {token: '<PASSWORD>'}

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

location.search = queryString.stringify(parsed);

console.log(location.search);
// ?foo=unicorn&ilike=pizza
```


## API

### queryString.parse(*string*)

Parse a query string into an object. Leading `?` or `#` are ignored, so you can pass `location.search` or `location.hash` directly.

### queryString.stringify(*object*)

Stringify an object into a query string.


## Nesting

This module intentionally doesn't support nesting as it's not specced and varies between implementations, which causes a lot of [edge cases](https://github.com/visionmedia/node-querystring/issues).

You're much better off just converting the object to a JSON string:
<commit_msg>mention stupid Firefox bug - fixes #13<commit_after># query-string [![Build Status](https://travis-ci.org/sindresorhus/query-string.svg?branch=master)](https://travis-ci.org/sindresorhus/query-string)

> Parse and stringify URL [query strings](http://en.wikipedia.org/wiki/Query_string)


## Install

```sh
$ npm install --save query-string
```

```sh
$ bower install --save query-string
```

```sh
$ component install sindresorhus/query-string
```


## Usage

```js
console.log(location.search);
// ?foo=bar

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

console.log(location.hash);
// #token=<PASSWORD>

var parsedHash = queryString.parse(location.hash);
console.log(parsedHash);
// {token: '<PASSWORD>'}

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

location.search = queryString.stringify(parsed);

console.log(location.search);
// ?foo=unicorn&ilike=pizza
```


## API

### queryString.parse(*string*)

Parse a query string into an object. Leading `?` or `#` are ignored, so you can pass `location.search` or `location.hash` *([doesn't work in Firefox](https://github.com/sindresorhus/query-string/issues/13))* directly.

### queryString.stringify(*object*)

Stringify an object into a query string.


## Nesting

This module intentionally doesn't support nesting as it's not specced and varies between implementations, which causes a lot of [edge cases](https://github.com/visionmedia/node-querystring/issues).

You're much better off just converting the object to a JSON string:

{'fraction_non_alphanumeric': 0.15655709928837683, 'fraction_numerical': 0.0013554727211114877, 'mean_word_length': 5.0, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 9, 'https://': 7, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2784997', 'n_tokens_mistral': 981, 'n_tokens_neox': 938, 'n_words': 237}