In Express.js, req.path is a string with the pathname of the request URL. For /users?sort=desc, it is '/users' — the query string is left out.
Use it for clean path checks and logging. Query values belong on req.query. For the full original path + query, use req.originalUrl. See also req.baseUrl when middleware is mounted.
Syntax
Read req.path in your Express.js route handler. Start with this line.
Express
req.path
Call
What it does
req.path
Primary signature.
Install with npm install express. Create the app with const app = express() before you use this API in an Express.js tutorial project.
Always call next(). Filtering must not block other routes.
Non-API paths skip the log./home continues quietly.
Compatibility
Runtime Support
req.path is an Express.js request property. It runs on a Node.js server (Express 5 needs Node.js 18+). Browsers do not execute it — they only send HTTP requests to your app.
✓ Server · Express 4 & 5
req.path
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.pathExpress 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 is a string with the pathname part of the request URL — no query string. For /users?sort=desc, req.path is '/users'.
No. Query values live on req.query. req.path is pathname only.
Inside mounted middleware, the mount point is not included. Under app.use('/admin', …) for /admin/new, req.path is '/new'.
req.originalUrl keeps the full original path plus query. req.path is the current pathname without query (and without the mount prefix in mounted middleware).
No. It is a server-side Express request property. Browsers only send the HTTP request; your app reads req.path on the server.