URL Encode / Decode

Percent-encode text for URLs and query strings, or decode %XX sequences back to readable text.

Back to tools

Form encoding (application/x-www-form-urlencoded) instead of %20.

How to URL encode and decode text

This tool percent-encodes text so it can be placed safely in a URL, and decodes percent-encoded strings back into readable text. Switch direction with the Encode to URL and Decode URL tabs. It is useful for building query parameters by hand, reading encoded values from server logs and redirect URLs, and debugging why an API receives a different value than you sent.

Characters are converted to UTF-8 bytes and each byte is written as % plus two hex digits, so accented letters, non-Latin scripts and emoji all work. A Use + for spaces switch handles the HTML form style where spaces are written as +. Everything runs in your browser.

How to use it

  1. Choose Encode to URL to percent-encode text, or Decode URL to turn %XX sequences back into characters.
  2. Type or paste into the Plain text box (encode) or the URL input box (decode). The output updates automatically after a short pause.
  3. Turn on Use + for spaces if you are working with query strings or form bodies in application/x-www-form-urlencoded format. Leave it off to encode spaces as %20 and to keep + as a literal plus when decoding.
  4. Read the result in URL output or Decoded text. Malformed input shows an error message in red in the output panel.
  5. Click Copy output, or use Swap input and output to move the result into the input and flip the mode.

Examples

Encoding a query parameter value

Every reserved character is encoded, including &, =, / and ?, so the value cannot break the surrounding query string. The é becomes its two UTF-8 bytes, %C3%A9.

Plain text
café & croissants = 2/3 off?
URL output
caf%C3%A9%20%26%20croissants%20%3D%202%2F3%20off%3F

The same value with Use + for spaces on

With Use + for spaces turned on, spaces become + instead of %20, which matches how browsers encode HTML form submissions. Everything else is unchanged.

Plain text
café & croissants = 2/3 off?
URL output
caf%C3%A9+%26+croissants+%3D+2%2F3+off%3F

Decoding a form-encoded query string

In Decode URL mode with Use + for spaces on, the + signs become spaces and %C3%A3 becomes ã. With the switch off, the output would be name=Jane+Doe&city=São+Paulo.

URL input
name=Jane+Doe&city=S%C3%A3o+Paulo
Decoded text
name=Jane Doe&city=São Paulo

What gets encoded

The encoder uses JavaScript's encodeURIComponent. It leaves letters, digits and the characters - _ . ! ~ * ' ( ) alone and encodes everything else, including the URL delimiters :, /, ?, #, &, = and +. That makes the output safe to drop into a single query parameter value or a single path segment.

Because it encodes delimiters, the tool is not meant for a complete URL. Pasting https://example.com/search?q=a b&lang=en produces https%3A%2F%2Fexample.com%2Fsearch%3Fq%3Da%20b%26lang%3Den, which is only correct when the whole URL is itself a value, for example inside a redirect_uri or next parameter. To build a normal URL, encode each value separately and join them with literal ?, = and &.

Spaces: %20 or +

RFC 3986 encodes a space as %20, and that form is valid anywhere in a URL. HTML forms use the older application/x-www-form-urlencoded format, where a space is written as +. Servers that parse query strings usually accept both, but path segments do not treat + as a space.

  • Encoding with Use + for spaces off writes %20. With it on, %20 is replaced by +.
  • A literal plus sign in the input is always encoded as %2B, so it is never confused with a space.
  • Decoding with the switch on turns every + into a space before decoding. With it off, + is kept as a plus sign.

Decoding errors and double encoding

The decoder stops with Invalid percent-encoding. Check for a % that is not followed by two hex digits. when it finds a % that does not start a valid escape, such as in 100%, or a set of bytes that is not valid UTF-8, such as a lone %C3. A literal percent sign must be written as %25.

Double encoding is a frequent bug when values pass through several layers. Encoding %20 again produces %2520, and the server then receives the text %20 instead of a space. If an encoded value contains %25 followed by two hex digits, decode it once and look at the result: if it still contains %XX sequences, the value was encoded twice.

Tips

A few practical points when working with encoded URLs:

  • Encode at the point where a value enters a URL, and decode exactly once where it leaves. Encoding or decoding in more than one layer causes most URL bugs.
  • To break a full URL into its protocol, host, path and parameters, use the URL Parser & Analyzer. To add campaign parameters, use the UTM Builder.
  • Treat decoded values as untrusted input. Escape them before inserting them into HTML or SQL.
  • Input and settings are saved in this browser's local storage and never sent to a server. Clear input removes the saved text.

Related tools

More utilities that pair well with this one.

Frequently asked questions

Common questions about this tool.