Skip to content
K Knidox Search…
Computer Science · Encoding

URL Encode & Decode

Percent-encode text so it travels safely inside a URL — then decode it back, UTF-8 safe.

Direction
Scope

Component escapes reserved characters like & ? / = # — use it for one query value or path segment.

18 chars
Try an example — tap to load
Encoded output
hello%20world%20%26%20caf%C3%A9

URL encoding replaces characters that are unsafe in a web address with a “%” followed by their hexadecimal byte value. A space becomes %20, so “hello world” becomes hello%20world. Use component encoding for a single query value or path piece, and full-URL encoding to escape a whole address while keeping its structure.

What URL encoding is

URLs may only contain a limited set of ASCII characters, and some of those — like &, ?, #, and / — have special structural meaning. Percent-encoding (also called URL encoding) lets you carry any other character safely by writing it as a “%” plus the two-digit hexadecimal value of each byte. Spaces, accented letters, and symbols are all represented this way, so the address survives copy-paste, forms, and servers without being misread.

unsafe character → % + two-digit hex of each UTF-8 byte

A space is byte 0x20, so it becomes %20; é is bytes C3 A9, so it becomes %C3%A9.

Component vs full URL

The two scopes differ in what they leave untouched. Component (JavaScript’s encodeURIComponent) escapes reserved characters like &, ?, =, and / — correct when the text is a single query-string value or one path segment that must not break the surrounding URL. Full URL (encodeURI) preserves those structural characters, so it is meant for encoding an entire address that is already assembled.

  1. 1
    Choose Encode. The Encode direction turns readable text into percent-encoded output.
  2. 2
    Pick a scope. Use Component for one query value or path segment; use Full URL for a complete address.
  3. 3
    Type or paste your text. Enter hello world & café to see reserved and non-ASCII characters handled together.
  4. 4
    Read the output. In Component scope this becomes hello%20world%20%26%20caf%C3%A9 — spaces, the ampersand, and é are all escaped.
  5. 5
    Decode to reverse it. Switch to Decode, keep the same scope, and paste the encoded string to recover the original text.

Common URL encodings

Percent-codes for characters that must be escaped inside a query value or path segment.

CharacterEncodedNotes
space%20A literal space; some encoders use “+” in query strings instead
&%26Separates query parameters, so it must be escaped in a value
?%3FMarks the start of the query string
#%23Marks the start of a fragment/anchor
/%2FPath separator; escaped by component encoding, kept by full-URL
=%3DJoins a query key to its value
+%2BEscaped so it is not mistaken for a space in query strings

The “+” versus “%20” nuance

Both “+” and %20 can stand for a space, but only in the query string, and only under an older form-encoding rule (application/x-www-form-urlencoded). In a path, “+” is a literal plus sign, not a space. Because of this ambiguity, encodeURIComponent always uses %20 for spaces and escapes a real “+” as %2B. When you need to protect one value that will sit inside a larger URL, encode it as a component; encode the whole thing only once it is fully built, or you will double-escape the “%” signs.

What is the difference between encodeURI and encodeURIComponent?
encodeURI is for a whole URL and leaves structural characters like : / ? & # intact. encodeURIComponent is for one piece — a single query value or path segment — and escapes those reserved characters too, so it will not accidentally break the surrounding address.
Why does a space become %20?
A space is byte 0x20 in ASCII, and 20 is its two-digit hexadecimal value. Percent-encoding writes any unsafe byte as “%” plus its hex, so a space is %20. Spaces are not allowed raw in a URL.
When do I see “+” instead of %20?
Only in query strings using the older form-encoding rules, where “+” means a space. In a path, “+” is a literal plus sign. This tool follows encodeURIComponent, which always uses %20 and escapes a real “+” as %2B to avoid the ambiguity.
How are accented letters and emoji encoded?
They are first converted to their UTF-8 bytes, then each byte is percent-encoded. For example é is bytes C3 A9, so it becomes %C3%A9. Decoding reassembles the bytes back into the original character.
Why do I get a “Not valid percent-encoding” message?
Decoding fails when a “%” is not followed by two valid hex digits — for example a bare “%” or a truncated “%2”. Check that every percent sign has a complete two-character code after it.
Which reserved characters must I escape in a query value?
Escape & ? = # and / (plus space and “+”) inside a value, because they otherwise mark parameter boundaries or path structure. Component encoding does this for you; full-URL encoding deliberately leaves them alone.