Why does JSON need URL encoding before going into a query string?
JSON syntax uses { } [ ] : , and " — most of which are reserved or unsafe in URL components. An ampersand inside a JSON string would terminate the parameter prematurely; a brace would be rejected by strict parsers. Percent-encoding turns every unsafe byte into %XX so the value survives intact through routers, gateways, and proxies.
Should I JSON.stringify first or percent-encode first?
Stringify first, then encode. JSON.stringify produces a UTF-8 string that represents the structure; encodeURIComponent then escapes the bytes that URL components forbid. This tool does both in one click — you paste raw JSON, it validates the input, stringifies the parsed value (compacting whitespace), and encodes the result.
What is the practical URL length limit for embedded JSON?
Most browsers and CDNs cap URLs around 2,048 to 8,192 characters. Because percent-encoding inflates each non-ASCII byte 3x and each reserved character 3x, encoded JSON gets long fast. If your encoded payload exceeds ~1,500 characters, switch to a POST body or store the JSON server-side and pass an opaque ID.
Will the output decode back to identical JSON?
Yes — value-for-value. Whitespace and key order are not preserved (JSON.stringify produces a canonical compact form), but every key, value, type, and Unicode character round-trips exactly. If preserving exact whitespace matters, encode the raw text with the URL Encode tool instead of this one.
Why does this validate the JSON first?
Because invalid JSON in a URL is silently broken — the receiver tries to parse it and fails with a generic 500. Validating before encoding means you find the typo here, not in production. The Error badge surfaces the exact parser message.
Can I use this for OAuth state or PKCE parameters?
Yes for OAuth state — encode the JSON state object once, paste it as the state parameter, and the authorization server returns it untouched. For PKCE code_verifier and code_challenge use the URL Encode tool with raw strings; PKCE uses base64url encoding, not JSON.
How does this handle nested objects and arrays?
Identically to top-level values. JSON.stringify walks the entire tree, the resulting string contains nested braces and brackets, and encodeURIComponent escapes them all. Arbitrarily deep nesting works as long as you stay under URL length limits.
Does this tool send my JSON to a server?
No. Validation, stringification, and encoding all happen in your browser. Open DevTools → Network and click Encode — no requests leave the page. Safe for tokens, IDs, or any sensitive structured data.