The query string is the part that comes after the URL path, and starts with a question mark ?.

For example:


Multiple query parameters can be added using &:


How do you get those query string values in Express?

Express makes it very easy by populating the Request.query object for us:

const express = require('express')
const app = express()

app.get('/', (req, res) => {


This object is filled with a property for each query parameter.

If there are no query params, it’s an empty object.

This makes it easy to iterate on it using the for…in loop:

for (const key in req.query) {
  console.log(key, req.query[key])

This will print the query property key and the value.

You can access single properties as well: //flavio
req.query.age //35

Download my free Express.js Handbook and check out my Node.js Course!

More express tutorials: