Skip to main content



Encode a set of form elements as a query string.

Use the FormData constructor to convert the HTML form to FormData, Array.from() to convert to an array, passing a map function as the second argument. Use and window.encodeURIComponent() to encode each field's value. Use Array.prototype.join() with appropriate arguments to produce an appropriate query string.

const serializeForm = (form) =>
Array.from(new FormData(form), (field) =>"=")
serializeForm(document.querySelector("#form")); //