Parse and stringify URL query strings in JavaScript
open sourceMITfree
query-string parses and stringifies URL query strings in JavaScript for browsers and Node.js. It handles arrays in several formats (brackets, indexes, comma-separated and more), can parse numbers and booleans or apply per-key types, sorts keys, skips null or empty values when stringifying, and parses or builds whole URLs including the fragment. Its README suggests the native URLSearchParams for simple cases. It's by Sindre Sorhus.
Problems it solves
- parse a URL query string into an object in JavaScript
- build a query string with arrays from an object
- read typed query parameters in a frontend app
Features
- parse and stringify query strings
- array formats: bracket, index, comma and more
- parse numbers, booleans and typed values
- skip null and empty values
- parse and build full URLs with fragments
