Skip to content

Announcing QueryStringJS

⚠ This package is now deprecated ⚠

Use URLSearchParams instead.

?query=string

I made a JavaScript query string parsing library because all the others sucked.

It's on NPM.

It has unit tests!

And it's pretty simple to use (example uses browserify):

var QueryString = require("querystringjs")(/* optional options go here */);
console.log(QueryString.parse("foo=bar"));
// {"foo":"bar"}

console.log(QueryString.stringify({ foo: "bar" }));
// "foo=bar"

And most importantly, it handles the things that most other solutions don't even think about:

console.log(QueryString.parse("foo=bar+baz"));
// {"foo": "bar baz"}

console.log(QueryString.parse("="));
// {"": ""}

console.log(QueryString.parse("foo=bar&foo=baz"));
// {"foo": ["bar", "baz"]}

// and many more!

So stop using whatever broken methods you've been using for query string parsing and start using this instead!