Skip to content

URL Encode and Decode

Encode text for safe use in a URL or decode a percent-encoded string, with clear errors for malformed escape sequences.

EverydayUpdated Free · No sign-up

How to use the URL Encode and Decode

  1. Pick what you want to work out using the tabs: Encode or Decode.
  2. Type or paste Text or URL to encode.
  3. Choose Method.
  4. Tick Encode spaces as + (HTML form style).
  5. Read your answer in the results panel. It updates as you type, and the breakdown, step-by-step working and any charts or tables appear below it.
  6. Use Share link to save or send the exact calculation, or Copy to paste the results elsewhere.

Why URLs need encoding

A URL can only contain a limited set of characters. Letters, digits and a few marks like – _ . ~ are safe. Other characters either have a special job (? starts the query, & separates parameters, # starts a fragment, / separates path segments) or are not allowed at all, such as spaces and non-English letters. Percent-encoding replaces each unsafe byte with % followed by two hexadecimal digits.

space → %20, & → %26, / → %2F, é → %C3%A9

Non-ASCII characters are first converted to UTF-8 bytes and each byte is encoded, which is why é becomes two escapes and the ✓ symbol becomes three (%E2%9C%93).

Component or full URL?

  • Component (JavaScript’s encodeURIComponent) encodes everything except letters, digits and – _ . ! ~ * ‘ ( ). Use it for a single query value or path segment, such as a search term, where & or / must not break the URL.
  • Full URL (encodeURI) leaves the characters that give a URL its structure, such as : / ? # & =, untouched. Use it to clean up a whole address that contains spaces or accented letters.

Example: the value a b&c=d/é encoded as a component is a%20b%26c%3Dd%2F%C3%A9. Encoding the whole URL https://x.com/a b?q=é gives https://x.com/a%20b?q=%C3%A9.

Plus signs and spaces

HTML forms submitted with the GET method write spaces as + rather than %20 (the application/x-www-form-urlencoded format). Tick the + option when encoding for that format, and when decoding form data so that + turns back into a space. In other parts of a URL a + is a literal plus sign.

Decoding errors

Decoding fails when a % is not followed by two hex digits, such as a truncated %A, or when the bytes do not form valid UTF-8, such as %FF on its own. Instead of a generic failure, this tool reports the position and the faulty sequence, so you can find a copy-paste error quickly.

Tips

  • Encode each value separately, then join them with & and =. Encoding a finished query string with the component method would also escape the separators.
  • Do not encode twice: %2520 is an encoded %20, a common bug.
  • Everything runs locally in your browser.

Frequently asked questions

What is URL encoding?

Also called percent-encoding, it replaces characters that are unsafe in URLs with % followed by the byte’s two-digit hex code. A space becomes %20.

What is the difference between encodeURI and encodeURIComponent?

encodeURI keeps characters that structure a URL, such as / ? & = and #. encodeURIComponent escapes them too, so it is the right choice for individual parameter values.

Should spaces be %20 or +?

Use %20 in paths and in general. The + form is only for HTML form data (application/x-www-form-urlencoded), usually in query strings.

Why does decoding fail with a malformed URI error?

Either a % is not followed by two hex digits or the escaped bytes are not valid UTF-8. The tool shows the position of the first bad sequence.