URL Encode / Decode

Encode special characters in a URL string to percent-encoded format, or decode a percent-encoded URL back to plain text.

Mode

Input length
0
Output length
0

URL Encoding Reference

Characters that must be percent-encoded in URLs. Encoding here escapes everything except letters, digits and - _ . ~ and works on UTF-8 text (so é becomes %C3%A9). Decoding converts only %XX sequences: a + stays a + (HTML form data uses + for a space, so replace those first if needed). Input is limited to 200,000 characters.

CharacterEncodedDescription
%20Space
!%21Exclamation
#%23Hash / Fragment
$%24Dollar
&%26Ampersand
'%27Apostrophe
(%28Left paren
)%29Right paren
*%2AAsterisk
+%2BPlus
,%2CComma
/%2FForward slash
:%3AColon
;%3BSemicolon
=%3DEquals
?%3FQuestion mark
@%40At sign
[%5BLeft bracket
]%5DRight bracket

Paste a whole link such as https://example.com/a b?x=1&y=2 into this tool and you get https%3A%2F%2Fexample.com%2Fa%20b%3Fx%3D1%26y%3D2, with the colon, slashes, question mark and equals signs all escaped, so it no longer works as an address. The reverse mistake, leaving a raw ampersand inside a value, quietly splits one parameter into two and loses data. Encode only the piece that needs it, such as a search term or a redirect target.

Percent-Encoding Rules, Byte by Byte

The text is first turned into UTF-8 bytes. Each byte outside the safe set becomes a percent sign followed by two hexadecimal digits of the byte value. The safe set, which this tool leaves as it is, is only A to Z, a to z, 0 to 9 and the four characters - _ . ~ (the unreserved characters of RFC 3986). Everything else is encoded, including space, / ? : # & = + and %, and also the marks ! ' ( ) * as %21 %27 %28 %29 %2A. A plain ASCII character therefore grows from 1 to 3 characters, é (2 bytes) becomes %C3%A9, the euro sign (3 bytes) becomes %E2%82%AC, and an emoji (4 bytes) becomes 12 characters.

Decoding goes the other way: every %XX is read as one byte, and the bytes are then read as UTF-8. Two details trip people up. A plus sign is not turned into a space, so hello+world%21 decodes to hello+world!, and the page notes this beside the reference table. And a truncated sequence such as %E0%A4%A cannot be read, so the output box turns red and shows a message instead of text. Decoding accepts either form of the marks, so %21 and a plain ! both come out as !.

Worked example: the input name=Tom & Jerry/café? is 22 characters. The = becomes %3D (hex 3D is 61), each space becomes %20, & becomes %26, / becomes %2F, é becomes %C3%A9 and ? becomes %3F. The result is name%3DTom%20%26%20Jerry%2Fcaf%C3%A9%3F, which is 39 characters: 15 untouched letters, 6 single-byte symbols at 3 characters each, and 6 for the é. The Output length counter on the page reads 39.

Here is one that uses the extra marks: Wow! (50% off*) is 15 characters and becomes Wow%21%20%2850%25%20off%2A%29, which is 29. The ! ( ) and * each take 3 characters, as do the two spaces and the percent sign. The tool accepts up to 200,000 characters of input.

How to Use This Calculator

  1. Pick Encode to escape text or Decode to restore percent-encoded text, using the two tabs at the top.
  2. Paste or type into the large text box; the output appears below it immediately, with no Calculate button.
  3. Check the Input length and Output length counters to see how much the string grew. The output counter shows a dash when the input could not be converted.
  4. Use Copy Output to take the result, or Use as Input to feed it back in, then Clear to start over. Both of the first two buttons are hidden while an error message is showing.

Frequently Asked Questions

Should I encode a full URL or only the value I am inserting?

Only the value. This tool escapes the separators too, so a complete address comes out unusable. Build the URL normally and run just the parameter value, such as a search phrase or a return address, through the encoder.

Why are ! ' ( ) * encoded here when some tools leave them alone?

They are legal in URLs, so many encoders, including the browser's built-in encodeURIComponent, leave them as they are. This page escapes them as %21 %27 %28 %29 %2A so that the output is safe in every context and matches the reference table. A server decodes either form to the same character.

Why does space become %20 and not a plus sign?

Percent-encoding uses %20. The plus-for-space habit belongs to HTML form submissions, and decoding here will not convert + back, so form-style data may need its plus signs replaced with spaces afterwards.

What does the invalid encoded string message mean?

A percent sign must be followed by two hex digits, and multi-byte characters must have all of their bytes. A lone %, a cut-off %E2%82 or a stray %ZZ cannot be decoded. A literal percent sign belongs in the text as %25.

What happens if I encode the same text twice?

It is encoded again: %20 turns into %2520, because the percent sign itself is escaped. The Use as Input button makes this easy to do by accident. If a link shows %25 sequences, decode once more.

Why does encoding fail on some text?

A single unpaired surrogate character, which can appear when text is cut in the middle of an emoji, is not valid UTF-8. The page then shows a red message instead of output. Remove the broken character and the rest encodes normally.