How to URL encode or decode
Type or paste into Input. With Encode selected you get the percent-encoded value; switch to Decode to read an encoded URL. ⇄ Swap sends the output back to the input so you can check a round trip.
| Text | URL encoded |
|---|---|
hello world | hello%20world |
a&b=c | a%26b%3Dc |
price: €10 | price%3A%20%E2%82%AC10 |
name@example.com | name%40example.com |
/path?x=1 | %2Fpath%3Fx%3D1 |
What percent encoding does
A URL may only contain a limited set of characters, and some of them have a job: ? starts the query, & separates parameters, # starts the fragment. To put any other character, or one of these as plain data, into a URL, its UTF-8 bytes are written as % plus two hex digits. That's why €, three bytes in UTF-8, becomes %E2%82%AC.
This tool encodes like JavaScript's encodeURIComponent: everything except letters, digits and - _ . ! ~ * ' ( ) is encoded. That's what you want for a single query parameter value or path segment.
Spaces: %20 or +?
Both mean a space, in different places. HTML forms send query strings as application/x-www-form-urlencoded, where a space is +. In the path of a URL, + is a literal plus sign and a space must be %20. The encoder here always writes %20, which works everywhere. The decoder treats + as a space, because encoded values you paste usually come from query strings.
URL encoding in code
// JavaScript
encodeURIComponent('a b&c') // "a%20b%26c"
decodeURIComponent('a%20b%26c') // "a b&c"
new URLSearchParams({ q: 'a b' }).toString() // "q=a+b"
// Java (form encoding: spaces become +)
URLEncoder.encode("a b&c", StandardCharsets.UTF_8) // "a+b%26c"
URLDecoder.decode("a+b%26c", StandardCharsets.UTF_8) // "a b&c"
# Python
from urllib.parse import quote, unquote, quote_plus
quote('a b&c', safe='') # 'a%20b%26c'
quote_plus('a b&c') # 'a+b%26c'
unquote('a%20b%26c') # 'a b&c' Encode each parameter value on its own, not the whole URL. Encoding a full URL also encodes its ://, ? and &, which breaks it. JavaScript's encodeURI is the variant that leaves those structural characters alone.
Double encoding
If you see %2520, the value was encoded twice: the % of %20 was encoded again as %25. Decode it twice with Swap to get the original, then fix the code so it encodes only once, usually by not encoding a value that a library such as URLSearchParams or Spring's UriComponentsBuilder encodes for you.
Frequently asked questions
What is URL encoding?
URL encoding, or percent encoding, writes characters that aren't allowed in a URL as % followed by two hex digits for each UTF-8 byte. A space becomes %20 and € becomes %E2%82%AC.
Should a space be %20 or +?
Use %20 in URL paths. In query strings sent by HTML forms, + also means a space. %20 is accepted in both places, so it is the safer choice.
Why do I get an error when decoding?
The text contains a % that is not followed by two hex digits, for example a literal 100% in the value. Encode the % itself as %25.
Which characters are not encoded?
Letters A–Z and a–z, digits 0–9 and - _ . ! ~ * ' ( ) are left as they are, the same as JavaScript's encodeURIComponent.
Is the text sent to a server?
No. Encoding and decoding run in your browser.
Related tools
Encode / Decode for Base64, HTML entities and hex, Base64 decoder, cURL to code, JSON escape and regex tester.