The size of URLSearchParams counts entries, including repeated keys. It can differ from the number of distinct parameter names.
Worked example
import { URLSearchParams } from "node:url";
console.log(new URLSearchParams("a=1&a=2").size);Result
2Implementation notes
Replacing a key can collapse existing repeated values. Use append when a second occurrence is meant to remain part of the request.
Try it yourself
Add the same filter twice and compare both counts.
Open the Node.js example →Editorial date January 2, 2026 · Published December 6, 2026