
Query string <-> JSON
Convert a URL query string to a JSON object or back, with repeated keys folding into an array. Runs on your device, nothing is uploaded.
Query string <-> JSON reads a URL query string into a JSON object, folding a repeated key into an array of every value seen, or runs the reverse with URLSearchParams. Converting to a query string refuses a top-level array or scalar. An array on the JSON side becomes a key repeated once per element, never one list value.
Questions
How are repeated keys handled?
They fold into a JSON array of every value seen for that key, in the order they appeared in the query string.
What does json-to-qs require?
A JSON object at the top level; an array or scalar there is refused.
How is an array value on the JSON side encoded?
As one repeated key, appended once per array element, rather than a single encoded list value.
Does it strip a leading ? or #?
Yes, either is stripped before parsing. A pasted URL fragment therefore works as it is, without trimming it first.
What handles the encoding and decoding?
The browser's own URLSearchParams, the same parser a page uses, so plus signs and percent escapes follow the web rules.