URL Encode / Decode

URL encoding (percent-encoding) replaces unsafe characters like spaces and & with codes such as %20 and %26. Paste text or a URL below to encode it, decode it, or break it into its parts.

Reviewed by ToolNook editorial team Updated Sources

Mode

What is URL encoding?

URLs may only contain a limited set of characters. Spaces, accented letters, emoji and characters with special meaning in a URL, such as &, ?, # and /, have to be written in a safe form called percent-encoding. Each byte of the character's UTF-8 representation is written as % followed by two hexadecimal digits: a space becomes %20 and é becomes %C3%A9.

Getting this wrong is a common source of bugs: a search term containing & splits a query string in two, and an unencoded # cuts the rest of a URL off. This tool encodes and decodes correctly, and breaks a URL into its parts so you can see exactly what a server will receive.

How to use it

  1. Choose Encode or Decode.
  2. Pick Component to encode a single value, such as a query parameter, or Full URL to encode a whole address while keeping its structure.
  3. Tick Spaces as + for HTML form-style encoding (application/x-www-form-urlencoded).
  4. Paste your text. The output and, for full URLs, a table of every part and query parameter appear instantly.

Component vs full URL encoding

CharacterComponentFull URL
space%20%20
/%2F/ (kept)
? & =%3F %26 %3Dkept
é%C3%A9%C3%A9

Use component encoding for anything you insert into a URL, like a search term or file name. Use full URL encoding only to clean up an address that is already structured correctly.

Example

To build https://example.com/search?q= with the search term “café & crème”, encode the term as a component: caf%C3%A9%20%26%20cr%C3%A8me. Without encoding, the & would start a new, empty parameter and the search would only receive “café ”.

More worked examples

Search link: the term “50% off & free shipping” must be encoded as 50%25%20off%20%26%20free%20shipping inside a query string, or the & would start a new parameter.

Common mistakes to avoid

  • Encoding a whole URL as a component. That also encodes : and /, breaking the address.
  • Double encoding. %20 becomes %2520; decode first if unsure.
  • Using percent-encoding for page slugs. Make readable slugs with the text to slug converter instead.

Sources and methodology

The calculations on this page follow these published standards and references. The code is covered by automated tests against known values.

Frequently asked questions

Should spaces be %20 or +?

Both are common. %20 is correct everywhere in a URL; + means a space only in query strings submitted by HTML forms. When in doubt, use %20.

Why do I get an error when decoding?

The input contains a % sign that is not followed by two valid hex digits, or a sequence that is not valid UTF-8. Encode literal % signs as %25.

Is URL encoding the same as Base64?

No. URL encoding only replaces unsafe characters and leaves the rest readable. Base64 rewrites all of the data into a different alphabet.

Does encoding twice cause problems?

Yes. Double encoding turns %20 into %2520, which servers read literally. Decode first if you are unsure whether text is already encoded.