Skip to content

node:querystring

How Elide supports Node's legacy querystring module for parsing and formatting query strings: it matches Node; prefer URLSearchParams in new code.

On this page

node:querystring matches Node’s querystring; use URLSearchParams in new code.

Example

js
// 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"));
utf-8 · js · Lines: 7

elide run qs.mjs prints:

text
{"tag":["a","b"],"q":"hello world"}
q=caf%C3%A9%20%26%20co&page=2
a%20b a b
utf-8 · text · Lines: 3

Reference

Status: Full · Not measured · since 1.1.0

Exports

ExportKindStatusNotes
parse()functionFullParses a URL query string into a key-value object
stringify()functionFullSerializes an object into a URL query string
escape()functionFullPercent-encodes a string for use in a query string
unescape()functionFullDecodes a percent-encoded query string component
encode()functionFullAlias for stringify(); serializes an object into a query string
decode()functionFullAlias for parse(); parses a query string into a key-value object

Was this page helpful?