Last Updated: February 25, 2016
· ChrisMissal

jQuery - Turn JavaScript Object into query string

The method to turn an object directly into a query string with jQuery is the param method:

var obj = { name: 'chris', id: 21 };
var queryString = $.param(obj);
// results in : 'name=chris&id=21'

See: http://api.jquery.com/jQuery.param/

3 Responses
Add your response


Not trying to be rude, but how is this a "pro tip"? All you did was pull a method from the jQuery docs and then linked to it?

over 1 year ago ·

@bluetidepro I suppose "pro tip" isn't always black and white. This just came out of a conversation and the answer wasn't easily found at first. When I realized how easy it was to do, I created the tip as mostly a reminder to myself. I figured others that didn't know about $.param might find it useful as well.

over 1 year ago ·

@ChrisMissal Fair enough! :)

over 1 year ago ·