JSON query-parameter lab · Updated November 11, 2026
Encode JSON for a URL Query Parameter Online
Serialize JSON first, then percent-encode that complete string as one parameter value. Raw braces, quotes, and ampersands can change how the outer query is split.
Measured Node and PHP outputs
Run date: November 11, 2026. Node.js v24.19.0 encodeURIComponent and PHP 8.5.12 rawurlencode produce the same encoded JSON for this fixture.
| Runtime | JSON text | Encoded value |
|---|---|---|
| Node.js v24.19.0 | {"filters":["a&b","c+d"],"page":2,"empty":""} | %7B%22filters%22%3A%5B%22a%26b%22%2C%22c%2Bd%22%5D%2C%22page%22%3A2%2C%22empty%22%3A%22%22%7D |
| PHP 8.5.12 | same JSON text | same encoded value |
Common failure
Do not concatenate raw JSON after ?. An inner & becomes an outer parameter. Build the URL with a URL API, decode the parameter once, then parse JSON. Percent-encoding is transport formatting, not encryption.
FAQ
Should I encode JSON twice?
No. Encode the JSON once as the parameter value. A second pass changes literal percent signs.
Can JSON contain arrays?
Yes. The serialized JSON keeps array order; the query parser only sees one encoded value.
For an inner URL value, see nested URL encoding. For repeated keys, see Query Parameters.