Registry / serialization / querystringify

querystringify

JSON →
library2.2.0jsnpmunverified

Querystringify is a lightweight and straightforward utility for parsing and stringifying URL query strings. Currently at version 2.2.0, its last publish was approximately six years ago, suggesting a maintenance or stable status with infrequent updates. It prioritizes simplicity over handling complex, deeply nested query string structures, explicitly advising users against using it for such scenarios. Unlike more feature-rich alternatives like `qs` or `query-string`, `querystringify` focuses on basic key-value pairs without extensive type conversion or array handling beyond simple repetition. Its primary differentiator is its minimal footprint and direct approach, making it suitable for environments where bundle size and strict query string interpretation are paramount. It was developed before `URLSearchParams` became widely available, offering a basic, compatible interface for both server and client-side usage via CommonJS.

npm install querystringify
INSTALL
IMPORT
SIG · QUERYSTRINGIFY
Q
querystringify
serializationjavascriptv2.2.0
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

qs
const qs = require('querystringify');
import qs from 'querystringify';
This package is primarily CommonJS. For ESM environments, bundlers are typically required to handle the CJS module. Native ESM support is not provided as of v2.2.0.
parse
const { parse } = require('querystringify');
Named import for `parse` function, primarily used for destructuring in CommonJS environments.
stringify
const { stringify } = require('querystringify');
Named import for `stringify` function, useful for destructuring or selective imports in CommonJS.

Demonstrates basic parsing of query strings with and without values, and stringifying objects with optional prefixes.

const qs = require('querystringify'); // Parsing a simple query string const parsed = qs.parse('?name=Alice&age=30&city=New%20York'); console.log('Parsed object:', parsed); // Expected: { name: 'Alice', age: '30', city: 'New York' } // Parsing with parameters without values const parsedNoValue = qs.parse('item1&item2=value2'); console.log('Parsed with no value:', parsedNoValue); // Expected: { item1: '', item2: 'value2' } // Stringifying an object into a query string const objToS = { product: 'laptop', price: '1200', inStock: '' }; const queryString = qs.stringify(objToS); console.log('Stringified query:', queryString); // Expected: product=laptop&price=1200&inStock= // Stringifying with a '?' prefix const prefixedQuery = qs.stringify({ color: 'blue', size: 'M' }, true); console.log('Stringified with prefix:', prefixedQuery); // Expected: ?color=blue&size=M // Stringifying with a custom '#' prefix const customPrefixedQuery = qs.stringify({ id: 'abc123', status: 'active' }, '#'); console.log('Stringified with custom prefix:', customPrefixedQuery); // Expected: #id=abc123&status=active
Debug
Known issues
gotchaQuerystringify is intentionally 'dumb' and does not support parsing complex, deeply nested objects or array syntaxes (e.g., `foo[bar]=baz` or `arr[]=1`). It treats all parameters as flat key-value pairs.
fix
For complex query string structures, consider more robust libraries like `qs` or `query-string`, or the native `URLSearchParams` API for simpler cases.
affects: >=1.0.0
gotchaThis package is primarily designed for CommonJS (`require`) usage. While bundlers can often handle it, direct ES Modules (`import`) usage might lead to errors or unexpected behavior without specific configuration.
fix
Use `const qs = require('querystringify');` for Node.js environments. For browser or modern environments, use a bundler (like Webpack, Rollup, Parcel) to handle CJS modules, or switch to a package with explicit ESM support.
affects: >=1.0.0
deprecatedFor modern JavaScript environments, consider using the native `URLSearchParams` API for basic query string operations. It offers a standardized and often more performant solution, especially in browsers.
fix
Evaluate if `new URLSearchParams(window.location.search)` for parsing or `new URLSearchParams({ key: 'value' }).toString()` for stringifying meets your needs before opting for external libraries.
affects: >=1.0.0
Errors
Common errors & fixes
SyntaxError: Cannot use import statement outside a module
Attempting to use `import qs from 'querystringify'` in a CommonJS module or environment where ESM is not configured.
fix
Change your import statement to `const qs = require('querystringify');` to use the CommonJS module.
qs.parse('foo[bar]=baz') returns { 'foo[bar]': 'baz' } instead of { foo: { bar: 'baz' } }
Querystringify does not support nested object parsing; it interprets square brackets as part of the key name.
fix
If nested object parsing is required, switch to a library like `qs` (often referred to as 'node-qs' or just 'qs') which explicitly handles such structures, or manually parse the resulting flat object.
qs.stringify({ arr: [1, 2] }) results in 'arr=1,2' or 'arr=1&arr=2' instead of 'arr[]=1&arr[]=2'
Querystringify has limited support for array stringification, treating arrays as comma-separated values or simple repeated keys depending on implementation, not typically using `[]` notation for arrays.
fix
For consistent array serialization using `[]` notation (e.g., `arr[]=1&arr[]=2`), use a library like `qs` or `query-string`, which offer explicit `arrayFormat` options.
Upgrade
Version history
2.2.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
6 hits · last 30 days
node
6
Resources
querystringify — npm install querystringify · libregistry