---
title: "parseFormData"
source: "https://github.com/remix-run/remix/blob/8905f3943706e1f53696ab83e70a84873cabfc90/packages/form-data-parser/src/lib/future/form-data.ts#L303"
---

# parseFormData

## Summary

Parses a [`Request`](https://developer.mozilla.org/en-US/docs/Web/API/Request) body into a [`FormData`](https://developer.mozilla.org/en-US/docs/Web/API/FormData)
object. This is useful when accessing the data contained in a HTTP `multipart/form-data` request
generated by a HTML `<form>` element.

This is a drop-in replacement for [the built-in `request.formData()` API](https://developer.mozilla.org/en-US/docs/Web/API/Request/formData)
with the main difference being the ability to customize the handling of file uploads. Instead of
keeping all files in memory, the `uploadHandler` receives each file as soon as its headers
arrive and can stream it to disk or a cloud storage service.

Parts are read in order, so the parser waits for the `uploadHandler`, and for any read of the
upload it started, to finish before moving on. Contents the handler doesn't read are discarded.
If the handler returns the upload itself, it is read into memory and stored as a `File`.

Accepts `multipart/*` and `application/x-www-form-urlencoded` media types.
Unsupported media types throw [`FormDataParseError`](/form-data-parser/class/FormDataParseError/) before the body is read.

## Signature

```ts
function parseFormData(request: Request, uploadHandler: FileUploadHandler): Promise<FormData>

function parseFormData(
  request: Request,
  options: ParseFormDataOptions,
  uploadHandler: FileUploadHandler,
): Promise<FormData>

```

## Parameters

### `request`

The `Request` object to parse

### `options`

Options for the parser

### `uploadHandler`

A function that handles file uploads. It receives a [`FileUpload`](/form-data-parser/future/class/FileUpload/) and may return any value that is valid in a `FormData` object