FormData.prototype.getAll
Returns all the values associated with a given key from within a FormData object
Syntax
formData.getAll(name)Parameters
| Parameter | Type | Description |
|---|---|---|
| name | string | The name of the key to retrieve all values for |
Return Value
An array of FormDataEntryValue items
Examples
const fd = new FormData()
fd.append('color', 'red')
fd.append('color', 'blue')
console.log(fd.getAll('color')) // ['red', 'blue']const form = document.querySelector('form') as HTMLFormElement
const fd = new FormData(form)
const selectedTags = fd.getAll('tags')
console.log('Tags:', selectedTags)function getMultipleFiles(input: HTMLInputElement) {
const fd = new FormData()
Array.from(input.files || []).forEach(f => fd.append('files', f))
return fd.getAll('files') as File[]
}Understanding FormData.prototype.getAll
The FormData.prototype.getAll method in JavaScript returns all the values associated with a given key from within a FormData object. It belongs to the FormData object and is one of the most widely used methods for working with formdata values in modern JavaScript and TypeScript applications.
The method signature is formData.getAll(name). It accepts 1 parameter: name. When called, it returns an array of formdataentryvalue items. Understanding when and how to use getAll() helps you write more expressive, readable code.
Common use cases for FormData.prototype.getAll include data transformation, input validation, API response processing, and building reusable utility functions. It works well alongside related methods like fetch-formdata-get, fetch-formdata-append, fetch-formdata-set, enabling you to chain operations together for complex data manipulation pipelines.
Browser support for FormData.prototype.getAll is excellent across all modern browsers including Chrome, Firefox, Safari, and Edge. It is also fully supported in Node.js and Deno. For older environments, transpilation with Babel or a polyfill may be needed.
Browser Compatibility
Supported in all modern browsers (Chrome, Firefox, Safari, Edge) and Node.js. Part of the ECMAScript standard.
Related Methods
FormData.prototype.getReturns the first value associated with a given key from within a FormData object
FormData.prototype.appendAppends a new value onto an existing key inside a FormData object, or adds the key if it does not already exist
FormData.prototype.setSets a new value for an existing key, or adds the key/value if it does not already exist, unlike append which adds another value
More FormData Methods
Other methods in the FormData object
Related Tools
More FormData Methods
Explore JavaScript Methods
Browse our complete reference of 410 JavaScript methods with syntax, examples, and explanations.