Query String to JSON
Parse a URL's query string into JSON, with PHP-style brackets for nested keys and lists, or build a query string from a JSON object.
Free · No sign-up · Your inputs stay in your browser
Input
Parse a query string into JSON
Output
Result
164 characters
Brackets follow PHP's convention: filter[status]=x becomes a nested key and tags[]=a&tags[]=b a list, which is what $request->query() and http_build_query() use. Node's URLSearchParams does not nest; the qs package does.
Runs in this browser. Nothing you paste is sent to a server.
About this tool
Method, assumptions, practical next steps, and limits.
Brackets are a convention
Nothing in RFC 3986 says what a query string means; it is opaque text after the ?. PHP decided that brackets build arrays, Rails and the qs package for Node followed, and Laravel's $request->query('filter.status') reads the nested result. URLSearchParams in the browser keeps keys flat, brackets and all.
Repeated keys
Without brackets, a repeated key such as ?tag=a&tag=b keeps only the last value in PHP, while URLSearchParams.getAll('tag') returns both. APIs consumed from several languages are safest with one value per key, or explicit brackets.