JSON URL Encode and Decode
ED-60Paste JSON to percent-encode it for a URL, or paste a URL-encoded JSON string to get readable, formatted JSON back.
Runs in your browser. Nothing is uploaded.
JSON (or a URL-encoded JSON string)
Result
How to use it
- Paste your JSON into the input box.
- Leave Remove whitespace on to make the URL shorter, or turn it off to encode the text exactly as typed.
- Click Encode JSON for URL and copy the result into your query string, for example ?filter=.
- To read a URL-encoded value, paste it and click Decode URL-encoded JSON.
What gets encoded
Every character except letters, digits and - _ . ! ~ * ' ( ) is replaced with percent codes. That includes braces, quotes, colons, commas, brackets, spaces and ampersands, so the whole JSON can sit in one query parameter without breaking the URL. Characters outside ASCII are encoded as their UTF-8 bytes, for example ã becomes %C3%A3. Numbers and strings inside the JSON are not changed.
Minify first, or not
JSON whitespace has no meaning, so removing it before encoding makes the URL shorter. The tool checks that the text is valid JSON when it does this and reports the line and column of any error. If you switch the option off, your text is encoded as it is and does not have to be valid JSON, which is useful for fragments.
Plus signs and decoding
In form-style query strings a space is often written as +. Tick the plus option to use + instead of %20 when encoding, and to read + as a space when decoding. Decoding turns the percent codes back and, with Format on, parses the result as JSON and indents it. If the decoded text is not valid JSON, turn Format off to see the raw text.
Error messages and what to do
| Message | What it means | Fix |
|---|---|---|
Not valid percent-encoding | A % is not followed by two hex digits, or the bytes are not UTF-8. | Check for a cut-off value or a stray percent sign. |
Unexpected | The JSON is not valid. The message gives the line and column where parsing stopped. | Fix the JSON, or turn off the whitespace option to encode the text as it is. |
Questions people ask
How do I URL encode JSON?
Paste the JSON and click Encode JSON for URL. Quotes, braces, colons and other special characters become %XX codes, so the whole document can be passed as one query parameter. Copy the result after the = in your URL.
How do I decode URL-encoded JSON?
Paste the encoded text and click Decode URL-encoded JSON. The percent codes are turned back into characters and, if Format is on, the JSON is pretty-printed. Tick the plus option if spaces were written as +.
Should I send JSON in a query string at all?
Short filters are fine, but URLs have length limits that vary by browser and server, and they appear in logs. For large or sensitive payloads, send JSON in a POST body instead.
Why is my encoded JSON so long?
Each special character becomes three characters, such as %22 for a quote. JSON has many quotes, braces and colons, so the result is much longer than the input. Removing whitespace first helps a little.
What is the difference between %20 and +?
Both can stand for a space in a query string. %20 works everywhere in a URL. + means a space only in form-style query strings. Use the plus option only if the receiver expects that style.
Does encoding change my JSON data?
No. The values are not altered, and decoding returns the same characters. Only the whitespace between tokens can be removed, and only when you leave that option on.
About this tool
Encoding checks that the text is valid JSON, optionally removes the whitespace between tokens, and percent-encodes every character that is not a letter, digit or one of - _ . ! ~ * ' ( ). Quotes, braces, colons, commas and ampersands are all encoded, so the result is safe as a single query value such as ?filter=. Non-ASCII characters are encoded as UTF-8 bytes. Numbers and strings inside the JSON are not changed. If you turn off whitespace removal, the text is encoded as typed and is not required to be valid JSON. Decoding reverses the percent-encoding and, if the option is on, requires the result to be valid JSON.