Software development · Frontend development

FormData (JavaScript)

In Spanish: FormData
See in the galaxyCopy link
Updated: 12/11/2026Reading: 2 min

Description

FormData is a JavaScript interface that allows easily constructing a set of key/value pairs representing form fields. This interface is especially useful for sending form data via HTTP requests, such as those made through AJAX. FormData facilitates the manipulation of form data, allowing key/value pairs to be added, deleted, or modified dynamically. One of its most prominent features is the ability to handle files, which allows for the uploading of binary files, such as images or documents, along with other form data. Additionally, FormData is compatible with the Fetch and XMLHttpRequest APIs, making it a versatile tool for modern web development. Its use simplifies the process of collecting and sending data, improving the developer experience and optimizing user interaction with web applications.

History

FormData was introduced as part of the HTML5 specification, which began development in the 2000s. The specification sought to improve the interoperability and functionality of forms on the web. As web applications became more complex and dynamic, the need for a more efficient way to handle form data became evident. FormData became a key solution to facilitate data collection and submission, especially in the context of applications that require file uploads. Its implementation has been widely adopted in modern browsers since its introduction.

Uses

FormData is primarily used in web application development to send form data asynchronously. It allows for file uploads along with other form data, which is essential in applications that require uploading images, documents, or any other type of file. Additionally, it is commonly used in combination with the Fetch and XMLHttpRequest APIs to perform POST requests, which improves the user experience by avoiding page reloads. It can also be used to build dynamic forms where fields can be added or removed in real time.

Examples

A practical example of using FormData is in an image upload application. When selecting an image from a form, a FormData object can be created and the image can be added along with other data, such as the username. Then, this object can be sent to a server using the Fetch API. Another case is in registration forms, where data such as name, email, and a profile picture can be sent in a single request.

Glosarix on your device

Install
×
Enable Notifications Ok No