req.body undefined 🟩 Node.js

Express: req.body is undefined / {} (body parser missing)

Express didn’t parse the request body because no body-parsing middleware matched the request’s Content-Type.

Seen on: Node.js

Meaning

Express needs express.json() for JSON and express.urlencoded() for form posts. multipart/form-data needs multer/busboy. The middleware must be registered before the routes.

Common causes

  • express.json() not registered (or registered after routes)
  • Client not sending Content-Type: application/json
  • Form data needing urlencoded or multer
  • Wrong body parser for the type

⚡ Quick fix

  1. app.use(express.json()) before routes
  2. Send the correct Content-Type
  3. Use multer for file uploads

Detailed fix by platform

Node.js

  1. javascript
    app.use(express.json());
    app.use(express.urlencoded({ extended: true }));

How to diagnose

  1. Middleware — Registered and before routes?
  2. Header — Content-Type of the request

🧠 Still stuck? Analyze your error

Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.