# qs — card for AI agents

Query string parser with nesting and array support.

Category: Utilities · npm package `qs` · latest version 6.17.1 (checked 2026-11-01)
Install: `npm install qs`
License: BSD-3-Clause (permissive)

In your own product (generator, app, hosted service): **yes**. Permissive license: ship it inside your own product, closed or open source, and keep its license and copyright notice.

## Numbers (AgentGid data)
- Gid Score: 68.1 (#483 of all tools, 55 of 408 in its category)
- Used in 18 public projects set up for AI coding agents (0.3%)
- Downloads last week: 278,326,512 (as of 2026-11-24), +44.4% over 4 weeks
- GitHub stars: 8,952 (as of 2026-11-24)
- Last push: 2026-11-24

## Often used with
Axios 66.0%, ts-node 34.0%, ESLint 70.0%, lint-staged 32.0%, TypeScript 82.0%, Express 28.0%

## Links
- AgentGid page: https://agentgid.com/tools/qs/
- Homepage: https://github.com/ljharb/qs
- Repository: https://github.com/ljharb/qs


## qs: turn web address filters into objects and back

qs is a small free JavaScript library for the part of a web address after the question mark. It turns text like filter[color]=blue&filter[size][]=M into a ready object your code can read, and turns such objects back into that text. It has built-in limits, so a hostile address cannot make it build huge or deep objects.

### Where to use it
- Read shop filters from the address: A product list page reads color, sizes and page number from the address bar as one tidy object, so shared links open with the same filters.
- Build links with filters: Your app turns the filters a person picked into a link or a request address another service understands, with arrays written the way that service expects.
- Refuse hostile addresses on a server: A public search page gets odd addresses from bots; your server rejects ones nested too deep or with huge list numbers instead of quietly reshaping them.
- Send form data to older servers: Some older services want data sent like a filled-in web form; qs turns your object into that text before you send it.
- Comma lists in short links: A marketing link carries tags=red,green; your page reads it as a list of two tags without extra code.
- Keep admin table views in links: An admin page stores sorting, column filters and page size in its address, so a teammate opens exactly the same view from a pasted link. (idea, not from the official pages)

### How to start
- Add qs to your project (pin the version, for example qs@6.17.1), then load it and parse or build a query string.

```
var qs = require('qs');
var assert = require('assert');

var obj = qs.parse('a=c');
assert.deepEqual(obj, { a: 'c' });

var str = qs.stringify(obj);
assert.equal(str, 'a=c');
```

- When you read location.search, drop the leading question mark with ignoreQueryPrefix.

```
var prefixed = qs.parse('?a=b&c=d', { ignoreQueryPrefix: true });
```

- Parse once with qs and run your checks on the object it returns, not on the raw text.

### License
Free to use in any project, including paid and closed-source ones, under the BSD 3-Clause license. Keep its copyright notice when you ship its files, and do not use the makers' names to promote your product.

### Good to know
- Every value comes back as text. A page number of 2 arrives as "2", and true arrives as "true"; convert them yourself.
- By default it nests only 5 levels deep and reads at most 1000 parameters; anything past that is kept flat or dropped, with no error.
- Lists stop at 20 items by position. A link with ids[25] gives an object with the key "25", not a list.
- Names that would overwrite built-in object parts, like hasOwnProperty, are skipped unless you turn that on.
- The browser's own URLSearchParams reads foo[bar] as one flat name, while qs reads it as nested. Do not check with one and use the other.

Checked 2026-11-11 against: https://github.com/ljharb/qs/blob/main/README.md, https://github.com/ljharb/qs/blob/main/LICENSE.md, https://github.com/ljharb/qs/blob/main/CHANGELOG.md, https://github.com/ljharb/qs/blob/main/.github/THREAT_MODEL.md, https://github.com/ljharb/qs/blob/main/.github/SECURITY.md, https://registry.npmjs.org/qs, https://registry.npmjs.org/qs/6.17.1, https://expressjs.com/en/guide/migrating-5.html, https://github.com/expressjs/body-parser/blob/master/README.md, https://github.com/axios/axios/blob/v1.x/README.md, https://github.com/sindresorhus/query-string/blob/main/readme.md

### Mistakes to avoid
- Don't: if (query.page > 1) or query.debug === true right after qs.parse → Do: Convert values yourself (Number(query.page), query.debug === "true") or validate with a schema (qs never converts types; in our demo page came back as the string "2".)
- Don't: Expecting nested req.query objects in Express 5 out of the box → Do: Switch the query parser back to "extended", or parse the raw query with qs yourself (Express 5 changed the default query parser to "simple", which keeps foo[bar] as a flat name.)
- Don't: Checking or signing the query with URLSearchParams and then reading it with qs → Do: Parse once with qs and run allow lists and checks on the parsed object (The two read names differently, so a check on one does not hold for the other.)
- Don't: Treating arrayLimit as a hard cap and reading ids as an array → Do: Set throwOnLimitExceeded: true, or check Array.isArray before use (Past the limit qs quietly returns an object keyed by index; in our run ids[25]=7 gave {"ids":{"25":"7"}}.)
- Don't: A lockfile pinning qs below 6.14.1 on a public server → Do: Update to 6.17.1 (or at least the newest patch of your minor line) (Before 6.14.1 the list limit did not apply to the [] form; 6.15.2 also changed how odd bracket keys parse.)

### Questions
- Does it turn "2" into a number? No. All values come back as strings; convert numbers and booleans yourself, or check them with a schema library.
- Is it safe to parse addresses from strangers? It has limits on depth, parameter count and list size by default. To reject input past those limits instead of trimming it, turn on strictDepth and throwOnLimitExceeded.
- Does Express still use qs for req.query? Not by default in Express 5. Its default query parser changed from "extended" (the qs style) to "simple", so nested brackets are not built for you.
- Can I make it encode spaces as + like HTML forms? Yes. Since 6.17.0 the WHATWG format writes spaces as +, the way URLSearchParams and form posts do.
- Can I use it in a paid product? Yes, under BSD 3-Clause; keep its copyright notice and license text with copies you ship.

---
AgentGid's catalog is curated: every entry was checked against the maker's official pages (registry, repository, license and pricing pages) on the date shown; a license value shows the quote it stands on wherever AgentGid has one. Usage numbers come from AgentGid's own scan of public repositories set up for AI coding agents. Claims by makers are reported, not tested by AgentGid.
