FormData

The FormData interface provides a way to easily construct a set of key/value pairs representing form fields and their values, which can then be easily sent using the XMLHttpRequest.send() method. It uses the same format a form would use if the encoding type were set to "multipart/form-data".

You can also pass it directly to the URLSearchParams constructor if you want to generate query parameters in the way a <form> would do if it were using simple GET submission.

An object implementing FormData can directly be used in a for...of structure, instead of entries(): for (var p of myFormData) is equivalent to for (var p of myFormData.entries()).

Note: This feature is available in Web Workers.

Constructor

FormData()
Creates a new FormData object.

Methods

FormData.append()
Appends a new value onto an existing key inside a FormData object, or adds the key if it does not already exist.
FormData.delete()
Deletes a key/value pair from a FormData object.
FormData.entries()
Returns an iterator allowing to go through all key/value pairs contained in this object.
FormData.get()
Returns the first value associated with a given key from within a FormData object.
FormData.getAll()
Returns an array of all the values associated with a given key from within a FormData.
FormData.has()
Returns a boolean stating whether a FormData object contains a certain key.
FormData.keys()
Returns an iterator allowing to go through all keys of the key/value pairs contained in this object.
FormData.set()
Sets a new value for an existing key inside a FormData object, or adds the key/value if it does not already exist.
FormData.values()
Returns an iterator allowing to go through all values contained in this object.

Specifications

Specification Status Comment
XMLHttpRequest
The definition of 'FormData' in that specification.
Living Standard FormData defined in XHR spec

Browser compatibility

DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
FormDataChrome Full support 7Edge Full support 12Firefox Full support 4
Notes
Full support 4
Notes
Notes Prior to Firefox 7, specifying a Blob as the data to append to the object, the filename reported in the Content-Disposition HTTP header was an empty string, resulting in errors on some servers. Starting with Firefox 7, the filename blob is sent.
IE Full support 10Opera Full support 12Safari Full support 5WebView Android Full support ≤37
Notes
Full support ≤37
Notes
Notes XHR in Android 4.0 sends empty content for FormData with blob.
Chrome Android Full support 18Firefox Android Full support 4
Notes
Full support 4
Notes
Notes Prior to Firefox 7, specifying a Blob as the data to append to the object, the filename reported in the Content-Disposition HTTP header was an empty string, resulting in errors on some servers. Starting with Firefox 7, the filename blob is sent.
Opera Android Full support 12Safari iOS Full support 5Samsung Internet Android Full support 1.0
FormData() constructorChrome Full support 7Edge Full support 12Firefox Full support 4IE Full support 10Opera Full support 12Safari Full support 5WebView Android Full support ≤37Chrome Android Full support 18Firefox Android Full support 4Opera Android Full support 12Safari iOS Full support 5Samsung Internet Android Full support 1.0
Support of for...ofChrome Full support 50Edge Full support 79Firefox Full support 44IE ? Opera ? Safari Full support 11WebView Android Full support 50Chrome Android Full support 50Firefox Android Full support 44Opera Android ? Safari iOS Full support 11Samsung Internet Android Full support 5.0
appendChrome Full support 7Edge Full support 12Firefox Full support 4
Notes
Full support 4
Notes
Notes Prior to Firefox 7, specifying a Blob as the data to append to the object, the filename reported in the Content-Disposition HTTP header was an empty string, resulting in errors on some servers. Starting with Firefox 7, the filename blob is sent.
IE Full support 10
Notes
Full support 10
Notes
Notes With the "Include local directory pass when uploading files to a server" option enabled, IE will change the filename inside the Blob on the fly. To have direct control of the sent filename, the developer should send the filename as the third parameter value, i.e. formData.append(name, value, filename).
Opera Full support 12Safari Full support 5WebView Android Full support 3
Notes
Full support 3
Notes
Notes XHR in Android 4.0 sends empty content for FormData with blob.
Chrome Android Full support 18Firefox Android Full support 4
Notes
Full support 4
Notes
Notes Prior to Firefox 7, specifying a Blob as the data to append to the object, the filename reported in the Content-Disposition HTTP header was an empty string, resulting in errors on some servers. Starting with Firefox 7, the filename blob is sent.
Opera Android Full support 12Safari iOS Full support 5Samsung Internet Android Full support 1.0
deleteChrome Full support 50Edge Full support 18Firefox Full support 39IE No support NoOpera Full support YesSafari Full support 11WebView Android Full support YesChrome Android Full support 50Firefox Android Full support YesOpera Android Full support YesSafari iOS No support NoSamsung Internet Android Full support 5.0
entriesChrome Full support 50Edge Full support 18Firefox Full support 44IE No support NoOpera Full support 37Safari Full support 11WebView Android Full support 50Chrome Android Full support 50Firefox Android Full support 44Opera Android Full support 37Safari iOS Full support 11Samsung Internet Android Full support 5.0
getChrome Full support 50Edge Full support 18Firefox Full support 39IE No support NoOpera Full support 37Safari Full support 11WebView Android Full support 50Chrome Android Full support 50Firefox Android Full support 39Opera Android Full support 37Safari iOS Full support 11Samsung Internet Android Full support 5.0
getAllChrome Full support 50Edge Full support 18Firefox Full support 39IE No support NoOpera Full support 37Safari Full support 11WebView Android Full support 50Chrome Android Full support 50Firefox Android Full support 39Opera Android Full support 37Safari iOS Full support 11Samsung Internet Android Full support 5.0
hasChrome Full support 50Edge Full support 18Firefox Full support 39IE No support NoOpera Full support YesSafari Full support 11WebView Android Full support YesChrome Android Full support 50Firefox Android Full support YesOpera Android Full support YesSafari iOS No support NoSamsung Internet Android Full support 5.0
keysChrome Full support 50Edge Full support 18Firefox Full support 44IE ? Opera Full support YesSafari Full support 11WebView Android Full support 50Chrome Android Full support 50Firefox Android Full support 44Opera Android ? Safari iOS Full support 11Samsung Internet Android Full support 5.0
setChrome Full support 50Edge Full support 18Firefox Full support 39IE No support NoOpera Full support 37Safari Full support 11WebView Android Full support 50Chrome Android Full support 50Firefox Android Full support 39Opera Android Full support 37Safari iOS Full support 11Samsung Internet Android Full support 5.0
valuesChrome Full support 50Edge Full support 18Firefox Full support 44IE No support NoOpera Full support 37Safari Full support 11WebView Android Full support 50Chrome Android Full support 50Firefox Android Full support 44Opera Android Full support 37Safari iOS Full support 11Samsung Internet Android Full support 5.0
Available in workersChrome Full support YesEdge Full support ≤18Firefox Full support 39IE No support NoOpera Full support YesSafari No support NoWebView Android Full support YesChrome Android Full support YesFirefox Android Full support YesOpera Android Full support YesSafari iOS No support NoSamsung Internet Android Full support Yes

Legend

Full support
Full support
No support
No support
Compatibility unknown
Compatibility unknown
See implementation notes.
See implementation notes.

See also