URL Encode

Percent-encode text so it is safe to use in a URL.

Local Your input is processed locally in your browser. Found a problem? Report an issue

What URL Encode does

URL Encode percent-encodes text with the same rules as JavaScript's encodeURIComponent, so it is safe to place in a query parameter value or a path segment.

URL Encode examples

The built-in sample

Input

say "hello" & <b>bye</b>

Output

say%20%22hello%22%20%26%20%3Cb%3Ebye%3C%2Fb%3E

This is the input that the Load sample button fills in.

Reserved characters are encoded too

Input

name=Ada Lovelace&next=/a/b?x=1#top (50% off!)

Output

name%3DAda%20Lovelace%26next%3D%2Fa%2Fb%3Fx%3D1%23top%20(50%25%20off!)

The equals sign, ampersand, slash, question mark, hash and percent sign are all encoded, so this text can be one parameter value. The brackets and the exclamation mark are left as they are.

Each output was produced by running this tool on the input above it.

How it works

Encoding follows JavaScript's encodeURIComponent (RFC 3986): letters, digits and - _ . ! ~ * ' ( ) are kept, and every other character is converted to its UTF-8 bytes, each written as %XX.

CharacterEncoded
space%20
&%26
=%3D
?%3F
/%2F
#%23
+%2B
%%25
é%C3%A9
€%E2%82%AC

Details and limits

  • Do not run a complete URL through this tool. The slashes, the question mark and the ampersands would be encoded and the result is no longer a working address. Encode each parameter value on its own.
  • A space becomes %20, never +. Both are understood in query strings, but only %20 is correct in a path.
  • These characters are never encoded: A-Z a-z 0-9 - _ . ! ~ * ' ( ).

Worked example: Percent-encoding a query parameter containing spaces, &, =, and UTF-8

Suppose a user searches for the literal phrase Q&A: 100% "free" ₹50? and you need to pass it safely inside ?query=... without breaking the URL structure:

  • Why raw insertion breaks the URL: In ?query=Q&A: 100% "free" ₹50?, the & immediately terminates the query parameter (query=Q) and starts a bogus parameter named A: 100%..., while the raw % triggers a URIError: URI malformed on the server because "% " is not followed by two hex digits!
  • UTF-8 percent-encoded output: Q%26A%3A%20100%25%20%22free%22%20%E2%82%B950%3F
  • Byte-by-byte mapping: & → %26, : → %3A, space → %20, % → %25, " → %22, ₹ (3 UTF-8 bytes) → %E2%82%B9, and ? → %3F, while unreserved characters Q, A, 1, 0, f, r, e, 5 stay plain ASCII.

Limits and what this tool cannot do

  • Encodes RFC 3986 reserved characters (:, /, ?, &, =): Because this tool uses encodeURIComponent rules meant for query parameter values and path segments, pasting a complete URL like https://example.com/a?b=1 encodes the :, /, ?, and = into https%3A%2F%2Fexample.com%2Fa%3Fb%3D1. Only encode the parameter *value* (1), not the entire URL structure.
  • Does not encode Internationalized Domain Names (IDN Punycode): Non-ASCII domain names like münchen.de use Punycode (xn--mnchen-3ya.de) in DNS, not percent-encoding.

Questions

Should a space be %20 or a plus sign?

This tool writes %20, which is valid everywhere in a URL. The plus sign means a space only in form-encoded query strings.

Why do some systems encode a space as + and others as %20?

RFC 3986 (the URI standard) encodes spaces as %20 (used in URL paths and encodeURIComponent). The HTML application/x-www-form-urlencoded specification (used by HTML <form> submissions and URLSearchParams) encodes spaces as + and literal plus signs as %2B.

Which 66 characters are 'unreserved' and never percent-encoded?

Under RFC 3986 §2.3, the 66 unreserved characters are uppercase A–Z (26), lowercase a–z (26), digits 0–9 (10), and four punctuation marks: hyphen -, underscore _, period ., and tilde ~.

What happens if I encode a string that is already percent-encoded?

Every % sign gets encoded again as %25—turning %20 into %2520. If your links show %2520, run the string through URL Decode once.