In Express.js, req.acceptsCharsets() checks the request’s Accept-Charset header and returns the first charset you offered that the client accepts (for example 'utf-8'). If none match, it returns false.
Use it when a client still sends charset preferences. For modern web apps, default to UTF-8 in responses — most browsers no longer send Accept-Charset at all.
Syntax
Call req.acceptsCharsets in your Express.js app. Start with this line.
(no Accept-Charset)
→ acceptsCharsets may be permissive / unmatched → || 'utf-8'
→ charset=utf-8
Accept-Charset: iso-8859-1
→ "iso-8859-1"
How It Works
Pass an array. Same idea as multiple arguments.
Use || 'utf-8'. Covers false and keeps a safe default.
Matches real browsers. They rarely send the header; UTF-8 is expected.
Still honors real preferences. A client that asks for iso-8859-1 can get it when you support it.
Compatibility
Runtime Support
req.acceptsCharsets() is an Express.js request method. It runs on a Node.js server (Express 5 needs Node.js 18+). Browsers do not execute it — and most no longer send Accept-Charset.
✓ Server · Express 4 & 5
req.acceptsCharsets()
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
req.acceptsCharsets()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 checks the Accept-Charset request header and returns the first charset you offered that the client accepts. If none match, it returns false.
Most modern browsers omit Accept-Charset and expect UTF-8. The Express method is still useful for clients that send the header, or for learning negotiation.
Fall back to utf-8 for a better user experience, or send 406 if your API must refuse unsupported charsets.
Use multiple arguments or an array, for example req.acceptsCharsets('utf-8', 'iso-8859-1') or req.acceptsCharsets(['utf-8', 'iso-8859-1']).
No. It runs on your Node.js server. Browsers only send headers; most no longer send Accept-Charset at all.