For exemple, i have 3 inputs
You can loop through the values using a forEach and update the object. Note: Could also use reduce to directly create the object
forEach
reduce
const obj = {}; const inputs = document.querySelectorAll("input"); inputs.forEach(({ name, value }) => { obj[name] = value }) console.log(obj);