Query String to JavaScript Object
Use this tool to quickly convert query parameters into JavaScript objects. Ideal for developers parsing URL data into structured variables.
Use this tool to quickly convert query parameters into JavaScript objects. Ideal for developers parsing URL data into structured variables.
This free tool helps developers convert query strings into JavaScript objects. Easily parse parameters from a URL into a usable JS object for your frontend or backend logic.
Input Query String:
name=John&age=30&city=Delhi
Output JavaScript Object:
{
"name": "John",
"age": "30",
"city": "Delhi"
}
Parsing a query string is the reverse of building one. The tool removes a leading question mark if present and passes the rest to the browser's URLSearchParams, which splits on ampersands and equals signs and decodes percent sequences. Plus signs are decoded as spaces, following form-encoding rules. So q=rock+%26+roll yields the value rock & roll. Every value is a string, even when it looks like a number, because a URL carries no types. A parameter with no equals sign, such as debug, becomes a key with an empty string, and the result is printed as indented JSON.
Repeated names are common, for example when a form has several checkboxes with the same name. The first occurrence is stored as a string, and the second turns the entry into an array holding both values, in the order they appeared. This means a key may be a string in one URL and an array in another, so downstream code should handle both. Bracket syntax such as ids[]=1&ids[]=2 is not interpreted specially: the key is literally ids[]. A fragment after a hash sign is not removed, so paste only the query part.
A query string is the part of a URL that contains parameters, starting after a ?, like: ?name=John&age=30.
Yes, just paste the part after the "?" or include it — the tool handles both.
Yes, if multiple keys are the same, they’ll be grouped into arrays.
They are decoded to the original characters, so %40 becomes @ and %C3%A9 becomes the accented letter e. Plus signs are also turned into spaces according to form-encoding rules.
A key written without an equals sign, such as debug, is kept and given an empty string as its value. The same applies to a key followed by an equals sign and nothing else.