In Express.js, express.json() is built-in middleware that parses incoming requests with a JSON body and stores the result on req.body. It only looks at requests whose Content-Type matches the type option (default application/json).
Use it for APIs that accept JSON from fetch, mobile apps, or other servers. Register it with app.use()before routes that read the body. It runs on your Express server — not in the browser.
Syntax
Call express.json in your Express.js app. Start with this line.
Express
express.json([options])
Call
What it does
express.json([options])
Primary signature.
Install with npm install express. Create the app with const app = express() before you use this API in an Express.js tutorial project.
Optional. Passed to JSON.parse as the reviver (for example turn ISO strings into Date).
options.verify
Optional. verify(req, res, buf, encoding) — inspect the raw buffer before parse; throw to abort.
options.defaultCharset
Optional. Charset when the request omits one. Default 'utf-8'.
Return Value
express.json() returns a middleware function. Mount it with app.use(express.json()) (optionally with options). The return value is that middleware — not a parsed body.
Express
const jsonParser = express.json({ limit: '100kb' });
app.use(jsonParser);
// Same idea inline:
app.use(express.json());
Express.js Examples
Example 1 — Parse a JSON Body into req.body
Mount the parser, then echo the parsed object from a POST route.
Parser runs first. Bad JSON never becomes a usable object on req.body.
Error middleware catches it. The four-argument (err, req, res, next) handler runs when parsing fails.
Return a clear status. Clients get 400 and a short JSON error message.
Pass other errors on. Unrelated errors call next(err) so other handlers can deal with them.
Compatibility
Runtime Support
express.json() is Express.js built-in middleware. It runs on a Node.js server (Express 5 needs Node.js 18+). Browsers do not execute it — they only send JSON over HTTP.
✓ Server · Express 4.16+ & 5
express.json()
Works wherever Express runs: Node.js is the primary target. Bun and Deno can run many Express apps with compatibility layers. Not available in the browser.
ServerNode.js runtime API
Node.js18+ for Express 5 · 14+ typical for Express 4
Supported
BunExpress-compatible server apps
Supported
DenoVia npm compatibility / adapters
Supported
express.json()Express on Node.js
Bottom line: Study and run these examples with Node.js and the express package. Copy a snippet into a local file and start the server with node.
Frequently Asked Questions
It is built-in middleware that reads a JSON request body when Content-Type matches (default application/json), parses it, and sets req.body to the result.
Call app.use(express.json()) before any route that reads req.body. If you mount it after those routes, req.body will be empty or undefined.
express.json() parses JSON (typical for APIs and fetch). express.urlencoded() parses HTML form bodies (application/x-www-form-urlencoded). Many apps use both.
The parser fails and passes an error to Express. Without error middleware you may get a generic failure; with a four-argument error handler you can return a clear 400 JSON response.
No. It runs on your Node.js (or compatible) server. Browsers only send the HTTP request with a JSON body.