gitwtfhub

wtf is body-parser?

expressjs/body-parser — explained in plain English

Analysis updated 2026-06-26

5,500JavaScriptAudience · developerComplexity · 2/5Setup · easy

TL;DR

A small Node.js library used with Express web servers to automatically decode incoming request data, JSON, form submissions, raw binary, or plain text, and make it available as a JavaScript object.

Mindmap

mindmap
  root((repo))
    What it does
      Decodes raw request bytes
      Attaches to req.body
      Works with Express
    Supported Formats
      JSON
      URL-encoded forms
      Raw binary
      Plain text
    Configuration
      Size limits
      Encoding settings
      Compression support
      Custom verification
    Security
      Treat req.body as untrusted
      Validate before use

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

Why would anyone build with this?

REASON 1

Parse JSON sent by a mobile app or frontend to your Express API so you can read it as a normal JavaScript object

REASON 2

Handle HTML form submissions in an Express app by decoding URL-encoded form data automatically

REASON 3

Add payload size limits to your Express server to reject oversized requests before they reach your app logic

What's in the stack?

JavaScriptNode.jsExpress

How it stacks up

expressjs/body-parserchrisleekr/binance-trading-botcallmecavs/layzr.js
Stars5,5005,5075,508
LanguageJavaScriptJavaScriptJavaScript
Setup difficultyeasyhardeasy
Complexity2/54/52/5
Audiencedeveloperdeveloperdeveloper

Figures from each repo's GitHub metadata at analysis time.

How do you spin it up?

Difficulty · easy Time to first run · 5min

Install via npm. Does not handle file uploads or multipart forms, use multer or busboy for those cases.

No explicit license mentioned in the explanation.

Wtf does this do

When a web server receives data sent by a browser or app, that data arrives as raw bytes. Before a Node.js server can do anything useful with it, the data needs to be decoded into a usable format. body-parser is a small library that sits in the middle of that process and handles the decoding automatically. It is part of the Express.js ecosystem, the most widely used web framework for Node.js. The library supports four formats. JSON parsing reads data structured as key-value pairs, which is the most common format for modern APIs. URL-encoded parsing handles form submissions from HTML pages. Raw parsing keeps the data as-is in binary form. Text parsing reads the body as a plain string. Each parser is available separately, so a project can include only the formats it needs. Once body-parser processes an incoming request, the decoded data is attached to the request object under a property called req.body, where the rest of the application can read it. Each parser can be configured with options: a size limit to reject oversized payloads, encoding settings, whether to accept compressed data, and a custom verification function for extra checks before parsing begins. The README notes an important security consideration: because req.body contains data that came from the user, every property in it should be treated as untrusted and validated before use. A caller cannot assume that a field exists, has the expected type, or is safe to call methods on. The library does not handle file uploads or multipart form data, which have their own complexity. For those use cases, the README points to alternatives such as multer, busboy, and formidable. The full README is longer than what was shown.

Yoink these prompts

Prompt 1
Show me how to add body-parser to an Express app so I can read JSON data posted from a React frontend using req.body.
Prompt 2
How do I configure body-parser to reject requests larger than 1MB and return a proper error response in Express?
Prompt 3
I need to parse both JSON and URL-encoded form data in the same Express app. How do I set up multiple body-parser middleware for both formats?
Prompt 4
What security checks should I add after reading req.body with body-parser before using the data in my database query?

Frequently asked questions

wtf is body-parser?

A small Node.js library used with Express web servers to automatically decode incoming request data, JSON, form submissions, raw binary, or plain text, and make it available as a JavaScript object.

What language is body-parser written in?

Mainly JavaScript. The stack also includes JavaScript, Node.js, Express.

What license does body-parser use?

No explicit license mentioned in the explanation.

How hard is body-parser to set up?

Setup difficulty is rated easy, with roughly 5min to a first successful run.

Who is body-parser for?

Mainly developer.

View the repo → Decode another repo

This repo across BitVibe Labs

Don't trust strangers blindly. Verify against the repo.