Skip to content

Repository files navigation

querystring

Parse and stringify query strings, nested + arrays.

npm version npm downloads bundle size license CI

Zero dependencies - ~2 KB gzipped - TypeScript - Node + Bun + browser


Install

bun add @knownasrazi/querystring
npm install @knownasrazi/querystring

Usage

import { parse, stringify } from "@knownasrazi/querystring";

parse("a=1&b=2"); // { a: "1", b: "2" }
parse("user[name]=razi&user[age]=30"); // { user: { name: "razi", age: "30" } }
parse("a[]=1&a[]=2"); // { a: ["1", "2"] }
stringify({ tags: ["a", "b"] }); // "tags=a&tags=b"
stringify({ nested: { x: "y" } }); // "nested[x]=y"

API

Export Description
parse(input, opts?) string -> Record<string, QueryValue>
stringify(data, opts?) Record<string, QueryValue> -> string

Options: nested, encode/decode flags.

Development

git clone https://github.com/knownasrazi/querystring.git
cd querystring
bun install
bun test
bun run build
bun run lint

License

MIT + Razi


querystring - urls that nest.

About

Parse and stringify query strings with nested object and array support.

Topics

Resources

Stars

6 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages