Express req.query Property

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

What you’ll learn

  • How to read URL query parameters with req.query.
  • How to handle optional filters, pagination, and sorting inputs.
  • How to convert and validate query values safely.
  • How req.query differs from req.params.

Usage syntax

javascript
req.query
req.query.page
req.query.search
1

Read pagination query params

javascript
app.get('/products', function (req, res) {
  var page = Number(req.query.page || 1);
  var limit = Number(req.query.limit || 10);
  res.json({ page: page, limit: limit });
});
2

Use optional filter query values

javascript
app.get('/search', function (req, res) {
  var keyword = req.query.q || '';
  var sort = req.query.sort || 'relevance';
  res.json({ keyword: keyword, sort: sort });
});

❓ FAQ

It is an object containing query string parameters from the URL.
They come from the part after ? in the URL, such as ?page=2&sort=asc.
Often yes, though parser behavior can vary; always validate and convert types explicitly.
req.query comes from query string, while req.params comes from route path segments.
No. Treat it as user input and validate before using in filtering, SQL, or business logic.
Did you know?

req.query provides parsed key-value pairs from the URL query string, and values should be validated before use.

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