Parsing Post Form Data Node.js Express

The above two answers are correct but now those methods are outdated. multer is a better method to access form data. Install it by the following command: npm install multer

some useful body parsers.

Body-type: parser

  • form-data: multer

  • x-www-form-urlencoded: express.urlencoded()

  • raw: express.raw()

  • json: express.json()

  • text: express.text()


The library which worked for me was express-formidable. Clean, fast and supports multipart requests too. Here is code from their docs

Install with:

npm install -S express-formidable

Here is sample usage:

const express = require('express');
const formidable = require('express-formidable');

var app = express();

app.use(formidable());

app.post('/upload', (req, res) => {
  req.fields; // contains non-file fields 
  req.files; // contains files 
});

The tool that worked was multiparty

app.post('/endpoint', function (req, res) {
    var form = new multiparty.Form();
    form.parse(req, function(err, fields, files) {
        // fields fields fields
    });
})