Express req.params Property

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

What you’ll learn

  • How to read dynamic route values from req.params.
  • How to work with single and multiple path parameters.
  • How to validate and convert parameter values safely.
  • How req.params differs from req.query.

Usage syntax

javascript
req.params
req.params.id
req.params.userId
1

Read single route parameter

javascript
app.get('/users/:id', function (req, res) {
  res.send('User ID: ' + req.params.id);
});
2

Use multiple route params

javascript
app.get('/users/:userId/posts/:postId', function (req, res) {
  var userId = req.params.userId;
  var postId = req.params.postId;
  res.json({ userId: userId, postId: postId });
});

❓ FAQ

It is an object containing named route parameters extracted from the URL path.
They come from route patterns like /users/:id or /posts/:postId/comments/:commentId.
Yes, they are usually strings and should be validated/converted when numeric values are expected.
req.params comes from route path segments, while req.query comes from the URL query string.
Yes, with middleware or app.param() you can validate and normalize param values.
Did you know?

req.params contains key-value pairs from named route segments like /users/:id.

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