Express req.is() Method

Beginner
⏱️ 8 min read
📚 Updated: May 2026
🎯 4 Code Examples

What you’ll learn

  • How to validate request payload types with req.is().
  • How to check JSON, form, and wildcard MIME patterns.
  • How to return proper status codes for unsupported payloads.
  • How req.is() differs from req.accepts().

Usage syntax

javascript
req.is(type)
req.is(type1, type2, ...)
1

Accept only JSON payloads

javascript
app.post('/api/orders', function (req, res) {
  if (!req.is('application/json')) {
    return res.status(415).send('JSON payload required');
  }
  res.send('Order accepted');
});
2

Support JSON or form data

javascript
app.post('/submit', function (req, res) {
  var type = req.is('json', 'urlencoded');
  if (!type) return res.status(415).send('Unsupported content type');
  res.send('Parsed as: ' + type);
});

❓ FAQ

It checks whether the request Content-Type matches one or more MIME patterns.
It returns the matched content type string, null in some no-body contexts, or false when no match is found.
Yes. You can pass multiple arguments like req.is('json', 'application/*').
No. req.is() checks incoming Content-Type. Use req.accepts() for Accept negotiation.
Yes, it helps validate expected payload format before processing body data.
Did you know?

req.is() checks the request Content-Type and returns the matched type (or false when it does not match).

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

4 people found this page helpful