---
hide_title: false
hide_table_of_contents: false
pagination_next: null
pagination_prev: null
---
# FormData()

The **`FormData()`** constructor creates a new `FormData` object.

## Syntax

```js
new FormData()
new FormData(form)
```

> **Note:** `FormData()` can only be constructed with `new`. Attempting to call it without `new` throws a `TypeError`.

### Parameters

- `form` _**optional**_
  - : An HTML `<form>` element — when specified, the `FormData` object will be populated with the form's current key/value pairs using the name property of each element for the keys and their submitted value for the values. File input elements are handled specially: their values are taken from the files selected by the user in the upload control.

### Return value

A new `FormData` object, pre-populated with form data if the optional `form` parameter was provided.

## Description

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

You can also append additional data to the `FormData` object after it's created using its various methods.

A `FormData` object can be used in a number of ways with other APIs:

1. It can be sent with the `fetch()` API
2. It works seamlessly with the `Request` and `Response` objects - it can be used directly as the body of a `Request` object
3. It can be obtained from a `Response` object using the `formData()` method
4. It can be passed directly to the `URLSearchParams` constructor

The transmitted data is in the same format that the form's `submit()` method would use to send the data if the form's encoding type were set to `"multipart/form-data"`.
