URL Encoder / Decoder
Encode a string for use inside a URL (or decode percent-escapes back to text). Shows component vs full-URI variants and base64url for token use.
Result
- encodeURIComponent (queries, path segments)hello%20world%20%26%20friends
- encodeURI (full URL — keeps :/?&=)hello%20world%20&%20friends
- application/x-www-form-urlencoded (form bodies — space→+)hello+world+%26+friends
- base64url (JWT / token-safe)aGVsbG8gd29ybGQgJiBmcmllbmRz
- UTF-8 bytes21
Step-by-step
- encodeURIComponent escapes everything except A-Z a-z 0-9 - _ . ~ ! * ' ( ).
- encodeURI is more permissive — it keeps reserved syntax characters (: / ? # [ ] @ ! $ & ' ( ) * + , ; =).
- Form encoding replaces %20 with + as required by application/x-www-form-urlencoded.
How to use this calculator
- Pick a direction.
- Encode mode: copy whichever variant you need (component / URI / form / base64url).
- Decode mode: paste any percent-escaped or base64url string and read the original text.
About this calculator
URL percent-encoding is the convention every web framework uses to embed non-URL-safe characters inside a URL. Reserved characters like &, =, ?, /, and space get rewritten as %XX (the hex of the UTF-8 byte). For a path segment or query-string VALUE you almost always want encodeURIComponent — encodeURI is much more permissive and is meant for re-escaping an already-built URL. This tool runs both, plus the form-encoding variant (space→+) and base64url for JWT-style token use.
How it works — the formula
encodeURIComponent: char ∉ [A-Za-z0-9-_.~!*'()] → %XX of UTF-8 byte
encodeURI: same, but also excludes reserved URI syntax: / ? # [ ] @ etc.
base64url: base64 with +→- /→_ and trailing = strippedPercent-encoding is byte-level: encode UTF-8 bytes one at a time. A multi-byte character produces multiple %XX sequences. Decoding reassembles the UTF-8 byte stream and re-decodes to a string.
Worked examples
- Inputs:
- mode=encode, text=hello world
- Output:
- hello%20world
- Inputs:
- mode=encode, text=&=?
- Output:
- %26%3D%3F (component) / &=? (URI)
- Inputs:
- mode=decode, text=%E4%B8%AD
- Output:
- 中 (U+4E2D)
Limitations
- encodeURI vs encodeURIComponent semantics follow WHATWG / RFC 3986 specs.
- base64url decode is attempted only when input matches the alphabet.
- No automatic URL parsing — for splitting a full URL into scheme/host/path/query use a URL parser.
Encodings round-trip exactly: decode(encode(x)) === x for any UTF-8 string.