📂
File System8M+/wkMIT

formidable

Formidable is a Node.js module for parsing form data, especially file uploads. Unlike Multer which is Express middleware, Formidable is framework-agnostic and w

Installation

npm
npm install formidable
yarn
yarn add formidable
pnpm
pnpm add formidable

Import

ESM
import formidable from 'formidable';

Quick Example

usage
import http from 'http';
import formidable from 'formidable';

const server = http.createServer(async (req, res) => {
  if (req.url === '/upload' && req.method === 'POST') {
    const form = formidable({ maxFileSize: 10 * 1024 * 1024 });
    const [fields, files] = await form.parse(req);
    res.end(JSON.stringify({ fields, files }));
  }
});

server.listen(3000);

About formidable

Formidable is a Node.js module for parsing form data, especially file uploads. Unlike Multer which is Express middleware, Formidable is framework-agnostic and works with any Node.js HTTP server including Express, Koa, Fastify, and the raw http module. The library streams uploaded files directly to disk rather than buffering them in memory, making it suitable for handling large file uploads without excessive memory consumption. Formidable supports multipart/form-data (file uploads), application/x-www-form-urlencoded (form submissions), and application/json (JSON bodies). The library provides event-based (form.on('file', ...)) and promise-based (form.parse(req)) APIs with progress tracking for upload monitoring. Configuration options include uploadDir for file destination, maxFileSize for upload limits, multiples for allowing multiple files per field, and keepExtensions for preserving original file extensions. Formidable handles file renaming, temporary file management, and proper cleanup of partially uploaded files. The library is often preferred over Multer in non-Express projects or when framework-agnostic file upload handling is needed. Formidable has been actively maintained since 2010 and is one of the most battle-tested file upload libraries in the Node.js ecosystem.

Quick Facts

Packageformidable
CategoryFile System
Weekly Downloads8M+
LicenseMIT
Installnpm install formidable

Related Packages

Browse npm Packages by Category

Explore our reference of 200 popular npm packages with install commands, examples, and quick-start guides.