URL Encoder / Decoder
Percent-encode and decode URLs. Use Component mode for encoding query values and path segments. Use Full URL mode to encode a complete URL while preserving its structure.
encodeURIComponent vs encodeURI
encodeURIComponent encodes everything except A-Z a-z 0-9 - _ . ! ~ * ' ( ) — use this for query parameter values and path segments. encodeURI additionally preserves ; , / ? : @ & = + $ # — use this when encoding a full URL. Common mistake: using encodeURI on a query value will leave & and = unencoded, breaking the query string.
Text to encode — typically a URL component: query parameter, path segment, or fragment
Unreserved characters (A–Z, a–z, 0–9, -, _, ., ~) are passed through unchanged per RFC 3986
All other characters (spaces, Unicode, symbols) converted to their UTF-8 byte sequence
Each byte written as %XX where XX is the uppercase hexadecimal value — e.g. space → %20
encodeURI preserves :, /, ?, #, & for full URLs. encodeURIComponent encodes everything for safe embedding in a query string.
String containing %XX sequences — from a URL, form submission, or API response
Each '%' followed by two hex digits is identified as an encoded byte
Each %XX converted to its numeric byte value — e.g. %20 → 0x20 (32 decimal)
Consecutive encoded bytes assembled and decoded as UTF-8 — handles multi-byte Unicode sequences
Human-readable string with all percent-encoded sequences replaced by their original characters
Spec: RFC 3986 §2.1 (percent-encoding), RFC 3987 (IRI), WHATWG URL Standard