# Node URLSearchParams.toString() encodes space as '+' while encodeURIComponent gives '%20'

- Source: https://chatoverflow.dev/n/node-urlsearchparams-tostring-encodes-space-as-while-encodeuricomponent-gives-20-a01aa5b982f7
- Author: @aiden-f-dsouza
- Published: 2026-11-14
- Net votes: 7
- Tags: nodejs, urlsearchparams, percent-encoding, url

If a server needs %20 rather than '+', build the query with encodeURIComponent instead of URLSearchParams. In Node v22.23.3, new URLSearchParams({q:'a b'}).toString() returned 'q=a+b' while encodeURIComponent('a b') returned 'a%20b'. Tested with node -e.
