URL Encoder and Decoder (Percent-Encoding)
Paste text to percent-encode it for a URL, or paste an encoded string to read it. Choose whether to keep the URL punctuation. It all happens in your browser and nothing is sent or saved.
Last reviewed
Encoded
price%3D5%20%26%20tax%3D10%25
29 characters
Encode only the parts of a URL that carry data, such as a query value, and not the whole address, or the slashes and question marks will be escaped too.
What percent-encoding is
A URL can only contain a limited set of characters. Anything else, such as a space, a non-English letter or a character with a special meaning in the address, must be written another way. RFC 3986, the standard for URL syntax, calls this percent-encoding: write a percent sign followed by two hexadecimal digits of the byte’s value. A space (byte 0x20) is %20. For characters outside ASCII, the text is first converted to bytes with UTF-8, and each byte is encoded, so é becomes the two bytes C3 and A9, written %C3%A9.
RFC 3986 recommends upper-case hexadecimal digits, which is what the tool writes. It reads both cases.
Which characters stay as they are
The RFC splits characters into two sets:
- Unreserved: upper- and lower-case letters, digits, hyphen, period, underscore and tilde. They are never encoded.
- Reserved: the general delimiters : / ? # [ ] @ and the sub-delimiters ! $ & ’ ( ) * + , ; =. They have jobs in a URL: the slash separates path parts, the question mark starts the query, the ampersand separates parameters and the equals sign joins a name to its value.
When one of these characters is part of your data, it must be encoded, or it will be read as punctuation.
Three ways to encode
| Mode | Keeps | Space becomes |
|---|---|---|
| A value inside a URL | A–Z a–z 0–9 - . _ ~ | %20 |
| A whole URL | the above plus the reserved characters | %20 |
| Form data | A–Z a–z 0–9 * - . _ | + |
The form rule comes from the WHATWG URL Standard, which defines the percent-encode set for application/x-www-form-urlencoded as every code point except ASCII alphanumerics and * - . _, and writes a space as +. Browsers use it when they submit an HTML form.
Worked examples
| Text | Value in a URL | Form data |
|---|---|---|
| price=5 & tax=10% | price%3D5%20%26%20tax%3D10%25 | price%3D5+%26+tax%3D10%25 |
| café | caf%C3%A9 | caf%C3%A9 |
| a/b?c | a%2Fb%3Fc | a%2Fb%3Fc |
| 100% (done) | 100%25%20%28done%29 | 100%25+%28done%29 |
| ~ok-1_2.3 | ~ok-1_2.3 | %7Eok-1_2.3 |
The first row has three characters with a meaning in a URL, the equals sign, the ampersand and the space, and a percent sign, which must itself be written %25. In the last row the tilde is unreserved in RFC 3986 but is encoded in form data.
Decoding
Decoding reverses the process. Each %HH becomes a byte, and the bytes are read as UTF-8 text. A percent sign not followed by two hexadecimal digits is an error, and so are bytes that are not valid UTF-8. For form data, tick the option to read + as a space. In an ordinary URL a plus sign is just a plus sign.
Common mistakes
- Encoding a whole address with the value rule. The slashes and colons are escaped and the link breaks.
- Encoding twice. %20 becomes %2520. Encode once, at the point you build the URL.
- Leaving out the percent sign. A literal % must be %25.
- Decoding + as a space in a path. Only form data uses it.
- Forgetting the UTF-8 step. Non-English text must be encoded as UTF-8 bytes.
Related tools: the base64 encoder and decoder for binary data, the JWT decoder, and the JSON formatter.
How it is calculated
The tool works through the characters of your text, converts each to UTF-8 bytes and writes the bytes that are not kept as %HH in upper case. It does not use the browser’s encodeURIComponent, whose set of kept characters is slightly different: it also leaves ! ’ ( ) * unencoded.
Frequently asked questions
What is URL encoding?
Also called percent-encoding. A character that is not allowed in a URL is replaced by % and the two hexadecimal digits of its byte value, so a space becomes %20 and an ampersand %26. Text is converted to UTF-8 bytes first.
Which characters are not encoded?
RFC 3986 calls the letters, digits, hyphen, period, underscore and tilde unreserved: they never need encoding. Everything else is encoded when it is part of a value, including the reserved characters : / ? # [ ] @ ! $ & ' ( ) * + , ; =.
Why is a space sometimes %20 and sometimes +?
%20 is the percent-encoding of a space and works everywhere in a URL. The plus sign is the rule for HTML form data, application/x-www-form-urlencoded, where the WHATWG URL Standard writes a space as +. Decode a + as a space only for form data.
Should I encode a whole URL?
Usually not. Encode the values that go into a URL, such as a query parameter, with the first mode. Encoding a whole address would turn its slashes and question marks into %2F and %3F and break it. The whole-URL mode keeps them.
Why does decoding say a % is not followed by two digits?
A percent sign in encoded text must be followed by exactly two hexadecimal digits. A bare % such as in 100% has to be written %25. The error gives the position of the faulty sign.
How are accented letters and emoji encoded?
Each character becomes its UTF-8 bytes, and every byte is percent-encoded. So é is %C3%A9 and an emoji takes four bytes, such as %F0%9F%98%80 for the grinning face.
Related calculators
- Base64 Encoder and DecoderType or paste text to encode it as base64, or paste base64 to decode it.
- JWT DecoderPaste a JSON Web Token.
- Hash GeneratorType or paste text and see its MD5, SHA-1, SHA-256, SHA-384 and SHA-512 hashes at once, as hex or base64.
- JSON Formatter and ValidatorPaste JSON to check it against RFC 8259 and format it with 2 or 4 spaces or a tab, or minify it.
- UUID GeneratorChoose version 4 (random) or version 7 (time-ordered) and how many to make.
- Epoch and Unix Timestamp ConverterEnter a Unix timestamp to see the date, or enter a date and time to get the timestamp.