{"id":13837,"library":"qs-parser","title":"QS - Query String Parser","description":"The `qs-parser` package, often referred to as `QS`, provides a lightweight utility for parsing, manipulating, and reconstructing URL query strings. It enables developers to easily extract individual query parameters, retrieve all parameters as an object, and verify the existence of specific keys. The library supports dynamic modification of query strings by adding new tokens, updating existing values, or completely removing parameters. A distinctive feature is its `go()` method, which can directly navigate the browser to the newly constructed URL. It handles URL encoding/decoding automatically and performs type conversion for numbers and arrays, with array parameters requiring a `[]` suffix in their key names. The current stable version is `0.4.8`. Given the inactivity in its GitHub repository, the project appears to be abandoned, meaning there are no active developments or a defined release cadence.","status":"abandoned","version":"0.4.8","language":"javascript","source_language":"en","source_url":"https://github.com/nire0510/qs","tags":["javascript","querystring","web","parser"],"install":[{"cmd":"npm install qs-parser","lang":"bash","label":"npm"},{"cmd":"yarn add qs-parser","lang":"bash","label":"yarn"},{"cmd":"pnpm add qs-parser","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"This package is primarily designed for CommonJS environments. For ESM, a bundler or `import * as QS from 'qs-parser';` might be required for interoperability. The default import style shown as 'wrong' is common for ESM modules, but this package exposes its API via CommonJS module.exports.","wrong":"import QS from 'qs-parser';","symbol":"QS","correct":"const QS = require('qs-parser');"},{"note":"The `QS` function is used directly as an initializer for a new instance, not as a class constructor with `new`.","wrong":"new QS('http://example.com?foo=bar').get('foo');","symbol":"QS","correct":"QS('http://example.com?foo=bar').get('foo');"},{"note":"When called without arguments in a browser environment, `QS()` automatically parses `window.location.search`. This behavior is not supported in Node.js where a URL string must always be provided.","wrong":"const QS_Instance = QS; QS_Instance().get('key');","symbol":"QS","correct":"QS().get('key');"}],"quickstart":{"code":"const QS = require('qs-parser');\n\n// Example URL for demonstration\nconst currentUrl = 'http://www.somedomain.com/somepage?foo=bar&email=nire0510%40gmail.com&number=345.678&cars%5B%5D=BMW&cars%5B%5D=Audi';\n\n// Initialize QS parser with a specific URL\nconst qs = QS(currentUrl);\n\nconsole.log('--- Read Operations ---');\nconsole.log('Original URL:', qs.url);\nconsole.log('Value of \"foo\":', qs.get('foo')); // Expected: 'bar'\nconsole.log('Value of \"email\":', qs.get('email')); // Expected: 'nire0510@gmail.com'\nconsole.log('Value of \"number\":', qs.get('number')); // Expected: 345.678\nconsole.log('Value of \"cars[]\":', qs.get('cars[]')); // Expected: ['BMW', 'Audi']\nconsole.log('All tokens:', qs.getAll()); // Expected: { foo: 'bar', email: 'nire0510@gmail.com', number: 345.678, 'cars[]': [ 'BMW', 'Audi' ] }\nconsole.log('Does \"foo\" exist?', qs.has('foo')); // Expected: true\n\nconsole.log('\\n--- Write Operations (Chainable) ---');\nqs.set('foo', 'newBar') // Change existing value\n  .set('dal', 'mon') // Add a new token\n  .remove('number'); // Remove a token\n\nconsole.log('Modified URL property (before .go()):', qs.url);\n// Expected URL to resemble: \"http://www.somedomain.com/somepage?foo=newBar&email=nire0510%40gmail.com&cars%5B%5D=BMW&cars%5B%5D=Audi&dal=mon\"\n\n// In a browser, calling .go() would navigate to the new URL.\n// For this runnable example, we'll avoid actual navigation.\n// console.log('\\nNavigating (if .go() was called):', qs.go());","lang":"javascript","description":"This example demonstrates how to initialize `qs-parser` with a URL, perform various read operations to retrieve parameters and check their existence, and then chain multiple write operations (set, add, remove) to modify the query string. It also shows the updated `url` property on the `qs` instance."},"warnings":[{"fix":"Evaluate alternative, actively maintained query string parsing libraries like `query-string` or `qs` (the more popular package by visionmedia).","message":"This package is currently abandoned. There will be no further updates, bug fixes, or security patches. Users should consider migrating to actively maintained alternatives.","severity":"breaking","affected_versions":">=0.4.8"},{"fix":"Avoid using `.go()` in environments where direct page navigation is undesirable. Instead, retrieve the modified URL from the `.url` property and integrate it with your application's routing mechanism if needed.","message":"The `.go()` method directly navigates the browser to the modified URL. This can cause unintended page reloads if not used carefully, especially in single-page applications where route changes are typically handled by client-side routers.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Ensure that array parameters in your URLs are formatted with the `[]` suffix (e.g., `key[]=value1&key[]=value2`) and use the same `get('key[]')` method to retrieve them.","message":"For parsing arrays from the query string, parameters must be explicitly suffixed with `[]` (e.g., `cars[]=BMW&cars[]=Audi`). If `cars=BMW&cars=Audi` is used, only the last value ('Audi') will be returned by `get('cars')`.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Use `npm install qs-parser --save` for Node.js projects or modern browser bundles. Bower should no longer be used for new projects.","message":"The README suggests installation via Bower (`bower install qs --save`), which is a deprecated package manager. npm is the recommended modern approach (`npm install qs-parser --save`).","severity":"deprecated","affected_versions":"<=0.4.8"}],"env_vars":null,"search_vec":"'0.4.8':114 'abandon':127 'activ':132 'ad':58 'appear':124 'array':98,100 'automat':90 'browser':80 'cadenc':138 'complet':65 'construct':84 'convers':94 'current':110 'defin':136 'develop':29,133 'direct':77 'distinct':69 'dynam':52 'easili':31 'enabl':28 'encoding/decoding':89 'exist':45,62 'extract':32 'featur':70 'github':120 'given':115 'go':73 'handl':87 'inact':117 'individu':33 'javascript':139 'key':48,107 'librari':50 'lightweight':17 'manipul':21 'mean':128 'method':74 'modif':53 'name':108 'navig':78 'new':59 'newli':83 'number':96 'object':41 'often':10 'packag':9 'paramet':35,38,67,101 'pars':20 'parser':4,8,142 'perform':92 'project':123 'provid':15 'qs':1,7,14 'qs-parser':6 'queri':2,25,34,55 'querystr':140 'reconstruct':23 'refer':11 'releas':137 'remov':66 'repositori':121 'requir':102 'retriev':36 'specif':47 'stabl':111 'string':3,26,56 'suffix':104 'support':51 'token':60 'type':93 'updat':61 'url':24,85,88 'util':18 'valu':63 'verifi':43 'version':112 'web':141","created_at":"2026-04-20T01:56:34.243118+00:00","updated_at":"2026-04-20T01:56:34.243118+00:00","problems":[{"fix":"For CommonJS, ensure `const QS = require('qs-parser');` is at the top of your file. For browser environments, verify the `<script src=\"...\"></script>` tag is correctly placed and loaded.","cause":"The library was not correctly imported or included in the project scope, or it's an ESM import attempting to use CJS-style module.","error":"ReferenceError: QS is not defined"},{"fix":"Call `QS` with a URL string (or without for `window.location` in a browser) to get an instance, then call methods on that instance: `QS('http://your-url.com').get('key');`.","cause":"Attempting to call methods on the `QS` function itself rather than an instance returned by calling `QS` with a URL.","error":"TypeError: QS(...).get is not a function"},{"fix":"Format your array parameters as `key[]=value` in the URL and retrieve them using `qs.get('key[]')`. For example, `QS('?items[]=a&items[]=b').get('items[]');`.","cause":"The library expects array query parameters to be explicitly suffixed with `[]` (e.g., `key[]=val1&key[]=val2`). Without this, it treats repeated keys as overwrites.","error":"Incorrect parsing of array parameters (only last value returned for `key=val1&key=val2`)"},{"fix":"Always provide a URL string argument when initializing `qs-parser` in a Node.js environment: `QS('http://example.com/path?foo=bar')`.","cause":"Calling `QS()` without any arguments in a Node.js environment. This attempts to parse `window.location.search`, which is a browser-specific global object.","error":"ReferenceError: window is not defined (in Node.js environment)"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/nire0510/qs","docs":null,"changelog":null,"pypi":null,"npm":"https://www.npmjs.com/package/qs-parser","openapi_spec":null,"status_page":null,"smithery":null,"categories":["http-networking","serialization"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-17","next_check":"2026-07-18","install_tag":null}}