JSON Formatter
Pretty-print, validate and minify JSON with precise error positions.
Developer & Security
Percent-encode and decode URLs and query strings.
This is the distinction that causes most URL bugs, and it comes down to which characters are treated as structural.
encodeURI assumes you are handing it a complete, valid URL and preserves the characters that give a URL its structure: : / ? # [ ] @ ! $ & ' ( ) * + , ; =. Use it on an entire URL you want to make safe for transport.
encodeURIComponent assumes you are handing it a single value that must survive being embedded inside a URL, and escapes everything except A-Z a-z 0-9 - _ . ! ~ * ' ( ). Use it on each parameter name and value individually.
Getting it backwards is how a redirect URL passed as a query parameter breaks: encode it with encodeURI and its own ? and & survive, so the outer URL now appears to have extra parameters.
| Character | encodeURI | encodeURIComponent |
|---|---|---|
| space | %20 | %20 |
| & | & (kept) | %26 |
| = | = (kept) | %3D |
| ? | ? (kept) | %3F |
| / | / (kept) | %2F |
| # | # (kept) | %23 |
| + | + (kept) | %2B |
Because two different encodings share the same syntax and disagree about the plus character.
In application/x-www-form-urlencoded — the format HTML forms submit and the format most query strings follow — a space is encoded as +, and a literal plus must be written %2B.
In RFC 3986 percent-encoding, a space is %20 and a plus is a literal plus.
So a URL containing ?q=C+++ means "C " to a form parser and "C+++" to a strict URI parser. When you are passing values that may contain a plus — phone numbers, math expressions, C++ — always encode it as %2B and the ambiguity disappears.
Technically yes, practically the browser handles it. RFC 3986 restricts URLs to a subset of ASCII, so any other character must be percent-encoded as its UTF-8 bytes. The word café becomes caf%C3%A9.
Modern browsers display the decoded form in the address bar, which makes it look as though non-ASCII URLs work natively. They do work, but the wire format is still percent-encoded, and that encoded form is what appears when a link is copied into an email, an analytics report, or a spreadsheet.
Domain names use a different mechanism entirely. Internationalized domains are encoded with Punycode, so münchen.de travels as xn--mnchen-3ya.de. This is also why homograph attacks are possible — Cyrillic and Latin letters that look identical produce different Punycode.
Double encoding happens when an already-encoded string is encoded again. The percent sign is itself a character that needs encoding, so %20 becomes %2520.
The symptom is a URL that visibly contains %2520, %253A or %2526, and a server that returns a 404 for a path that clearly exists. It usually comes from a value being encoded by application code and then encoded again by a framework or an HTTP client.
This tool detects the pattern and warns when the input appears to be already encoded, so you can decode once before re-encoding.
On every individual query parameter name and value, and on any path segment built from user input. Use encodeURI only on a complete URL.
Space, and the reserved delimiters : / ? # [ ] @ ! $ & ' ( ) * + , ; = when they appear inside a value rather than as structure. Also the percent sign itself.
That is correct behavior — a raw space is not legal in a URL. Browsers display it as a space but transmit %20.
Only in form-encoded query strings. In a path, + is a literal plus character. Encode a literal plus as %2B to avoid the ambiguity entirely.
Just the parameters, individually, before assembling the URL. Encoding the whole thing escapes the structural characters you need.
No. It is a transport encoding, fully readable and trivially reversible. It provides no privacy.
No. Encoding uses the native encodeURIComponent in this page.