An Express.js middleware that automatically parses and transforms query string values from strings to native JavaScript types: null, undefined, boolean, and number. Version 1.3.3 (May 2022) adds empty string conversion. It recursively handles nested objects and arrays. Compared to alternatives like qs (used by Express by default), this package provides a focused, zero-dependency solution with TypeScript type declarations and an ESBuild-based bundle, updated periodically since 2018.
npm install express-query-parserVerified import paths — ran on the pinned version, not inferred.
Demonstrates basic setup of the queryParser middleware with all parsing options enabled and shows the transformed query object.
Always pass an options object even if all defaults are used: queryParser({ parseNull: true, parseUndefined: true, parseBoolean: true, parseNumber: true })Access parsed values via req.query after middleware runs. Do not rely on previous references.
Handle null checks or disable parseNull if you need to preserve empty strings.
Set parseNumber: false if you want to keep numeric strings as strings, or validate numeric strings before parsing.
Consider alternatives like qs with custom decoder or a more actively maintained parser.
Use named import: import { queryParser } from 'express-query-parser'Ensure app.use(queryParser(...)) is called before any routes.
Set parseNull: true in options, or explicitly check version compatibility.
Disable parseNumber: false if you need to preserve numeric strings.
No dependency data recorded yet.