EasyPythonJavaScriptTypeScript

Parse Query String

Node.jsStringsURL

Parse a URL query string (without the leading ?) into an object.

solve('a=1&b=hello&c='){ a: '1', b: 'hello', c: '' }

Decode URI components. Empty input returns {}. Skip empty pairs.

Sample tests

Test #1Two pairs
Input: ["a=1&b=2"]
Output: {"a":"1","b":"2"}
Test #2Key without value
Input: ["flag"]
Output: {"flag":""}
Test #3Empty value
Input: ["a=&b=x"]
Output: {"a":"","b":"x"}
Test #4URL-encoded space
Input: ["name=John%20Doe"]
Output: {"name":"John Doe"}
Test #5Empty string
Input: [""]
Output: {}