0Pricing
JavaScript Academy · Lesson

The FormData Object

Build multipart payloads from forms.

What Is FormData?

FormData is a browser API for building a set of key/value pairs representing form fields and their values. It is the standard way to package data, including files, for sending to a server.

It encodes as multipart/form-data, which supports binary uploads.

Creating an Empty FormData

Construct an empty FormData and add fields one at a time with append.

const data = new FormData();
data.append('username', 'ada');
data.append('email', 'ada@example.com');

console.log(data.get('username'));

All lessons in this course

  1. The FormData Object
  2. Reading Files with FileReader
  3. Blobs and Object URLs
  4. Uploading Files with Fetch
← Back to JavaScript Academy