URL Encode / Decode

Encode and decode URLs and query strings safely for HTTP requests, redirects and API calls.

Back to all tools on ToolForge

More in Encoding & Decoding



Result

About URL Encode / Decode

This URL encode/decode tool converts text to and from percent-encoded format entirely in your browser. URL encoding (also called percent-encoding) is necessary because certain characters have special meanings in URLs or are not safe for transmission in HTTP requests.

Why URL Encoding Is Necessary

URLs can only contain a limited set of characters (ASCII letters, digits, and a few special characters). When you need to include:

Common URL Encoding Examples

Character Encoded Description
(space) %20 Space character
& %26 Query parameter separator
= %3D Key-value separator
? %3F Query string start
# %23 Fragment identifier
你好 %E4%BD%A0%E5%A5%BD Chinese characters

encodeURI vs encodeURIComponent

JavaScript provides two encoding functions with different behaviors:

Example:

Input: https://example.com/search?q=hello world&type=article

encodeURI result:
https://example.com/search?q=hello%20world&type=article
(keeps ? and & as-is)

encodeURIComponent result:
https%3A%2F%2Fexample.com%2Fsearch%3Fq%3Dhello%20world%26type%3Darticle
(encodes everything)

Common Use Cases

How to Encode or Decode URLs

  1. Enter your text: Type or paste the URL or text you want to encode/decode into the input box.
  2. Choose operation: Click "Encode" to convert text to percent-encoded format, or "Decode" to convert back to readable text.
  3. Review the result: The encoded or decoded text appears in the output box below.
  4. Copy or clear: Click "Copy Result" to copy the output, or "Clear" to start over.

Example Conversions

Encode example:

Decode example:

Frequently Asked Questions

What is URL encoding and why is it necessary?
URL encoding (also called percent-encoding) converts characters into a format that can be safely transmitted over the internet. Special characters like spaces, ampersands, and non-ASCII characters must be encoded because they have reserved meanings in URLs or are not valid in certain contexts. For example, a space becomes %20, and Chinese characters get encoded as multiple percent-encoded bytes.
What characters need to be encoded in a URL?
The following characters typically need encoding: spaces (%20), special symbols (<, >, #, %, {, }, |, \, ^, ~, [, ], `, @), and non-ASCII characters (Unicode). Reserved characters like ? & = / : have special meanings in URL structure and should only be encoded when they appear in parameter values, not as structural separators.
What is the difference between encodeURI and encodeURIComponent?
encodeURI() encodes a complete URI but preserves reserved characters that have structural meaning (? & = / : @). encodeURIComponent() encodes all special characters and should be used for individual URL parameter values. For example, encodeURI('https://example.com?a=1&b=2') keeps the ? and &, while encodeURIComponent would encode them as %3F and %26.
Why does my encoded URL look different in the browser address bar?
Modern browsers automatically decode percent-encoded characters in the address bar for display purposes, showing a more readable version. However, the actual URL being sent to the server remains encoded. This is a visual convenience feature and does not affect how the URL functions.
Can I decode a URL that was encoded multiple times?
Yes, but you need to decode it the same number of times it was encoded. Double-encoded URLs contain percent signs that are themselves encoded (e.g., %2520 instead of %20). Decode once to get %20, then decode again to get the space character.