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

# 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` allows you to store the file on disk or a
cloud storage service.

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 `File` object and may return any value that is valid in a `FormData` object