{"id":18351,"library":"express-query-parser","title":"express-query-parser","description":"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.","status":"active","version":"1.3.3","language":"javascript","source_language":"en","source_url":null,"tags":["javascript","express","query","parser","query-parser","typescript"],"install":[{"cmd":"npm install express-query-parser","lang":"bash","label":"npm"},{"cmd":"yarn add express-query-parser","lang":"bash","label":"yarn"},{"cmd":"pnpm add express-query-parser","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"Named export; package supports both ESM and CJS.","wrong":"const queryParser = require('express-query-parser')","symbol":"queryParser","correct":"import { queryParser } from 'express-query-parser'"},{"note":"CJS users must destructure the named export; no default export exists.","wrong":"const queryParser = require('express-query-parser').default","symbol":"queryParser","correct":"const { queryParser } = require('express-query-parser')"},{"note":"TypeScript users should import types with 'type' keyword to avoid runtime inclusion.","wrong":"import { QueryParserOptions } from 'express-query-parser'","symbol":"QueryParserOptions","correct":"import type { QueryParserOptions } from 'express-query-parser'"}],"quickstart":{"code":"import express from 'express';\nimport { queryParser } from 'express-query-parser';\n\nconst app = express();\n\napp.use(\n  queryParser({\n    parseNull: true,\n    parseUndefined: true,\n    parseBoolean: true,\n    parseNumber: true\n  })\n);\n\napp.get('/', (req, res) => {\n  // GET /?a=null&b=true&c=3.14&d[]=false&d[]=undefined\n  // req.query will be: { a: null, b: true, c: 3.14, d: [false, undefined] }\n  res.json(req.query);\n});\n\napp.listen(3000, () => {\n  console.log('Server listening on port 3000');\n});","lang":"typescript","description":"Demonstrates basic setup of the queryParser middleware with all parsing options enabled and shows the transformed query object."},"warnings":[{"fix":"Always pass an options object even if all defaults are used: queryParser({ parseNull: true, parseUndefined: true, parseBoolean: true, parseNumber: true })","message":"Parsing options are not part of the user-facing API and cannot be omitted; invalid options object shape will cause fallback to defaults.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Access parsed values via req.query after middleware runs. Do not rely on previous references.","message":"The middleware does not modify the original req.query object; it creates a new one. This may affect references stored elsewhere.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Handle null checks or disable parseNull if you need to preserve empty strings.","message":"Empty strings are converted to null (since v1.3.3). This may break code expecting empty strings.","severity":"gotcha","affected_versions":">=1.3.3"},{"fix":"Set parseNumber: false if you want to keep numeric strings as strings, or validate numeric strings before parsing.","message":"Number conversion uses JavaScript's Number() function; scientific notation like '1e2' becomes 100. May produce NaN for non-numeric strings.","severity":"gotcha","affected_versions":">=1.3.0"},{"fix":"Consider alternatives like qs with custom decoder or a more actively maintained parser.","message":"The package has not been updated since May 2022. No major bugs or CVEs reported, but it's in low-maintenance mode.","severity":"deprecated","affected_versions":">=1.3.3"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Use named import: import { queryParser } from 'express-query-parser'","cause":"Default import used instead of named import in ESM environment.","error":"TypeError: queryParser is not a function"},{"fix":"Ensure app.use(queryParser(...)) is called before any routes.","cause":"Middleware is executed after route handler or not applied at all.","error":"req.query is undefined after using queryParser"},{"fix":"Set parseNull: true in options, or explicitly check version compatibility.","cause":"parseNull option is disabled (default is true, but may be overridden).","error":"Expected null but got 'null' string"},{"fix":"Disable parseNumber: false if you need to preserve numeric strings.","cause":"parseNumber is enabled by default.","error":"Number '0' is converted to 0, but I wanted to keep it as string"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}