node:querystring matches Node’s querystring; use URLSearchParams in
new code.
Example
// qs.mjs
import querystring from "node:querystring";
const parsed = querystring.parse("tag=a&tag=b&q=hello%20world");
console.log(JSON.stringify(parsed));
console.log(querystring.stringify({ q: "café & co", page: 2 }));
console.log(querystring.escape("a b"), querystring.unescape("a%20b"));elide run qs.mjs prints:
{"tag":["a","b"],"q":"hello world"}
q=caf%C3%A9%20%26%20co&page=2
a%20b a bReference
Status: Full · Not measured · since 1.1.0
Exports
| Export | Kind | Status | Notes |
|---|---|---|---|
parse() | function | Full | Parses a URL query string into a key-value object |
stringify() | function | Full | Serializes an object into a URL query string |
escape() | function | Full | Percent-encodes a string for use in a query string |
unescape() | function | Full | Decodes a percent-encoded query string component |
encode() | function | Full | Alias for stringify(); serializes an object into a query string |
decode() | function | Full | Alias for parse(); parses a query string into a key-value object |