Cipher Utility

URL Decode and Encode

E-02

Percent-encoded text to plain text and back, with UTF-8. Runs in your browser; nothing is sent anywhere.

Encode:

How percent encoding works

  1. Keep letters, digits and - _ . ~
  2. Turn every other character into UTF-8 bytes.
  3. Write each byte as two hex digits.
  4. Put % in front of each pair.

Worked example

café bar = ?

é is two bytes, a space is one:

é → C3 A9   space → 20

caf%C3%A9%20bar

Cipher Utility reference card Catalog no. E-02

What URL encoding is

A URL may only contain a small set of characters. Others, such as spaces, accented letters, or symbols that already mean something in a URL (? & = / #), have to be written as percent codes: a % sign followed by the character's byte value in hex. This is called percent encoding or URL encoding.

https://example.com/search?q=café & bar https%3A%2F%2Fexample.com%2Fsearch%3Fq%3Dcaf%C3%A9%20%26%20bar

Decoding turns every %XX code back into its character, and reads UTF-8 sequences such as %C3%A9 as a single letter.

Common percent codes

CharacterCodeCharacterCode
Space%20+%2B
!%21/%2F
#%23:%3A
$%24=%3D
%%25?%3F
&%26@%40

Needed or all

With Encode set to Needed, the encoder keeps letters, digits and the four symbols - _ . ~ and encodes everything else. Those are the characters RFC 3986, the URL standard, says never need encoding. All also encodes - _ . and ~, for systems that expect every non-alphanumeric character as a percent code.

Encode a value, not the whole address

Encoding is meant for the pieces you put into a URL, such as a search term or a redirect address inside a query string. If you encode a complete address, its / and : are escaped too and it stops working as a link. Encode the value, then add it after the = sign.

Text encoded twice shows up as %2520 instead of %20, because the % sign itself became %25. Run the decoder twice to undo it.

Questions about URL encoding

How do I decode a URL?

Paste it into the box above with URL to Text selected. Every %XX code is turned back into its character, and + signs become spaces, as they do in form data.

What does %20 mean in a URL?

It is a space. URLs cannot contain spaces, so a space is written as % followed by its character code in hex, which is 20.

Is a space %20 or +?

Both appear. %20 is the general percent encoding and works anywhere in a URL. The + sign means a space only in query strings and form data sent by HTML forms. The decoder treats + as a space, and the encoder always writes %20.

Why do I see %2520 in a URL?

The text was encoded twice. The first pass turned a space into %20, and the second pass encoded the % sign itself as %25. Decode it twice to get the original back.

Should I encode a whole URL or just part of it?

Usually just a part, such as one query value. This encoder escapes / : ? and & as well, which is right for a value but breaks the structure of a full address.

Is my text sent to a server?

No. Encoding and decoding run in your browser with JavaScript, and nothing you paste leaves your device.