In Express.js, express.text() is built-in middleware that reads a text body and stores a string on req.body. By default it matches Content-Type: text/plain.
Use it when clients send plain text — notes, CSV snippets, or simple messages — not JSON objects. Mount it with app.use() before routes that read the string.
Syntax
Call express.text in your Express.js app. Start with this line.
Express
express.text([options])
Call
What it does
express.text([options])
Returns middleware that sets req.body to a string.
Install with npm install express. Create the app with const app = express() before mounting parsers.
Parameters
Parameter
Description
options
Optional. Parsing settings. Omit for defaults.
options.limit
Optional. Max body size. Default '100kb'.
options.type
Optional. Which Content-Type to parse. Default 'text/plain'.
options.defaultCharset
Optional. Charset when the request omits one. Default 'utf-8'.
POST /paste (small text)
→ 200 { "length": 12 }
POST /paste (body > 10kb)
→ Error: request entity too large (413)
How It Works
Set limit.{ limit: '10kb' } rejects bigger bodies.
Small text works. Route receives the string.
Large text fails. Parser errors before your handler.
Default is 100kb. Tighten it for public paste endpoints.
Compatibility
Runtime Support
express.text() is Express.js built-in middleware. It runs on a Node.js server (Express 5 needs Node.js 18+). Browsers do not execute it.
✓ Server · Express 4.17+ & 5
express.text()
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.text()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 middleware that reads matching text bodies into a string on req.body. Default Content-Type is text/plain.
express.json() parses JSON into objects or arrays. express.text() leaves the body as a plain string.
The Content-Type did not match text/plain (or your type option), or the parser was mounted after the route.
It uses the charset from Content-Type when present. Otherwise defaultCharset is utf-8.
No. It runs on your Node.js server. Browsers only send the HTTP request.