URL encoder and decoder
Percent-encode text for use in URLs, decode encoded URLs, and see every part of a URL at a glance.
Paste a full URL (starting with https://) to see its parts and parameters.
How it works
Anatomy of a URL
https://user@example.com:8080/docs/page?lang=en&q=json#intro
- Protocol:
https: - User info:
user@(rare, and a security risk in links) - Host and port:
example.com:8080 - Path:
/docs/page - Query:
?lang=en&q=json, a list of name=value pairs - Fragment:
#intro, which stays in the browser and is never sent to the server
Characters that need encoding
Letters, digits and - _ . ~ are always safe. Characters with a special meaning, such as ? & = # /, must be encoded when they're part of a value, and everything else (spaces, accented letters, emoji) is encoded as UTF-8 bytes.
Percent-encoding reference
Each character as a % and its UTF-8 bytes in hexadecimal, and what JavaScript's encodeURIComponent (Encode value above) and encodeURI (Encode full URL) make of it. The last two columns come straight from those functions, not from a list typed by hand.
| Character | Encoded | encodeURIComponent | encodeURI |
|---|---|---|---|
| Space | %20 | %20 | %20 |
!Exclamation mark | %21 | unchanged | unchanged |
"Double quote | %22 | %22 | %22 |
#Hash | %23 | %23 | unchanged |
$Dollar sign | %24 | %24 | unchanged |
%Percent sign | %25 | %25 | %25 |
&Ampersand | %26 | %26 | unchanged |
'Apostrophe | %27 | unchanged | unchanged |
(Opening bracket | %28 | unchanged | unchanged |
)Closing bracket | %29 | unchanged | unchanged |
*Asterisk | %2A | unchanged | unchanged |
+Plus sign | %2B | %2B | unchanged |
,Comma | %2C | %2C | unchanged |
/Slash | %2F | %2F | unchanged |
:Colon | %3A | %3A | unchanged |
;Semicolon | %3B | %3B | unchanged |
<Less than | %3C | %3C | %3C |
=Equals sign | %3D | %3D | unchanged |
>Greater than | %3E | %3E | %3E |
?Question mark | %3F | %3F | unchanged |
@At sign | %40 | %40 | unchanged |
[Opening square bracket | %5B | %5B | %5B |
]Closing square bracket | %5D | %5D | %5D |
éAccented letter (2 bytes) | %C3%A9 | %C3%A9 | %C3%A9 |
€Euro sign (3 bytes) | %E2%82%AC | %E2%82%AC | %E2%82%AC |
URL encoding in other languages
Every language has two flavours. Percent-encoding writes a space as %20 and works anywhere in a URL. Form encoding (application/x-www-form-urlencoded, what HTML forms send) writes it as +, which only means a space in a query string.
| Language | Function | Space becomes |
|---|---|---|
| JavaScript | encodeURIComponent(s) | %20 |
| JavaScript | new URLSearchParams({ q: s }).toString() | + |
| Python | urllib.parse.quote(s, safe='')Without safe='', / is left as it is | %20 |
| Python | urllib.parse.quote_plus(s) | + |
| PHP | rawurlencode($s) | %20 |
| PHP | urlencode($s) | + |
| Java | URLEncoder.encode(s, StandardCharsets.UTF_8)Form encoding, Java 10 and later | + |
| C# | Uri.EscapeDataString(s) | %20 |
| C# | WebUtility.UrlEncode(s) | + |
Encoded twice?
If a URL shows %2520 where you expect a space, it has been encoded twice: the % of %20 was itself encoded as %25. It usually happens when an already encoded value is passed through an encoding function again. The tool above points it out; decode once more to get the original text.
More tools
More on the bench
- JSON formatter and validatorPretty-print, minify and validate JSON, with the exact line of any error.
- Base64 encoder and decoderEncode text to Base64 and back, including URL-safe Base64 and emoji.
- Regex testerTest JavaScript regular expressions live, with groups, replace and common patterns.
- Text diff checkerCompare two texts or code snippets line by line or word by word.
- CSV to JSON and JSON to CSVConvert CSV to JSON and JSON to CSV, with delimiter detection.
- UUID (GUID) generatorGenerate random v4 or time-ordered v7 UUIDs, one or up to 1,000 at a time.
- JWT decoderRead the header and claims of a JSON Web Token, with expiry dates in plain English.
- MD5 and SHA hash generatorMD5, SHA-1, SHA-256, SHA-384 and SHA-512 hashes of any text, with a match check.
- Unix timestamp (epoch) converterEpoch seconds or milliseconds to a readable date and back in any time zone, ISO 8601 too.
- Lorem Ipsum generatorPlaceholder paragraphs, sentences or words, plain or as HTML.
Frequently asked questions
When should I encode a value and when a full URL?
Encode a value (encodeURIComponent) for anything you put inside a URL, such as a search term or parameter value: it escapes & = ? / and # too. Encode a full URL (encodeURI) only for a complete address that may contain spaces or non-English characters, which keeps its structure intact.
Why do spaces sometimes become + and sometimes %20?
Both mean a space. %20 is standard percent-encoding; + is used for spaces in HTML form submissions (application/x-www-form-urlencoded). The decoder here treats + as a space, which is right for query strings.
What does percent-encoding do?
It replaces characters that aren't allowed or have special meaning in URLs with a % followed by their UTF-8 bytes in hexadecimal. A space becomes %20, é becomes %C3%A9 and € becomes %E2%82%AC.
Is my URL sent anywhere?
No. Encoding, decoding and parsing all happen in your browser. That is important for URLs with tokens or personal data in them.