What is URL encoding in the context of URL Encoder & Decoder?
URL encoding (percent-encoding) replaces characters that are not allowed in URLs — like spaces, ampersands, and special symbols — with a % followed by their hexadecimal code. For example, a space becomes %20. It is defined in RFC 3986.
encodeURI vs encodeURIComponent?
encodeURIComponent encodes almost everything except A–Z a–z 0–9 - _ . ~ — use it for query values. encodeURI targets full URI strings and preserves characters that structure URLs (/, ?, :, #, etc.).
Should I encode the full URL or just the query string?
Encode individual query parameter values, not the full URL. Encoding the full URL with the wrong API can also encode the protocol (://), slashes, and domain — making it invalid. Encode only the values after the = sign.
Why does %20 sometimes appear as + in URLs?
HTML forms submit data as application/x-www-form-urlencoded, which uses + to represent spaces in the request body. In URL path segments and RFC 3986-compliant query strings, spaces are %20 and + means a literal plus sign. Use %20 in URLs you construct in code; decode + as space only when processing HTML form submissions.
What characters must always be percent-encoded in a URL?
Characters outside the unreserved set (A–Z, a–z, 0–9, -, _, ., ~) must be encoded when they appear as data rather than syntax. Key characters: space (%20), & (%26), = (%3D), + (%2B), ? (%3F), # (%23), / (%2F), : (%3A). encodeURIComponent handles all of these automatically.
What is percent encoding?
Percent encoding (URL encoding) is the RFC 3986 scheme where each byte of a UTF-8 character is written as % followed by two hexadecimal digits—e.g. space → %20, ampersand → %26. It is the same mechanism browsers and JavaScript encodeURIComponent use so reserved characters are not mistaken for URL syntax.
Is URL encoding good for SEO?
Search engines prefer clean, readable URLs in sitemaps and canonical tags—avoid encoding the entire path when plain ASCII works. Encoding still matters for UTM and analytics query parameters: encode each value with encodeURIComponent so & and = inside campaign names do not break parsing. Over-encoding visible slugs (%20 in paths users see) hurts readability; encode only the dynamic pieces.
Is it safe to decode URLs from emails or redirects?
Decoding is safe for inspection, but never trust a decoded redirect_uri or link from email without validating the destination host and path against an allowlist. Attackers hide open redirects behind percent-encoded URLs. Decode to debug, then confirm the plain URL matches your registered callback before using it in production redirects.
What is the difference between encodeURI and encodeURIComponent in JavaScript?
encodeURIComponent encodes all characters except unreserved characters (A–Z, a–z, 0–9, -, _, ., ~). It encodes structural URL characters like /, ?, &, =, :, # — making it safe for encoding a single query parameter value. encodeURI preserves structural characters so the result remains a valid URL. Rule: use encodeURIComponent for query values (utm_source=google+ads → utm_source=google%2Bads). Use encodeURI only when lightly sanitizing a complete URL you already control.
How do I encode a space in a URL?
Use %20 for a space in any URL you build in code. encodeURIComponent('hello world') → 'hello%20world'. Some older systems and HTML forms use + to represent a space in application/x-www-form-urlencoded form bodies, but %20 is the RFC 3986 standard for URLs. When in doubt, use encodeURIComponent which always produces %20, never +.
Why are special characters encoded in URLs?
URLs can only contain a safe subset of ASCII characters. Characters like &, =, ?, #, /, and space have reserved meanings as URL syntax delimiters. If they appear in data values, they must be encoded as %HH sequences so parsers don't mistake them for URL structure. For example, a query value containing & would break the parameter list without encoding: ?name=Tom&Jerry becomes ?name=Tom%26Jerry.
What does %20 mean in a URL?
%20 is the percent-encoded representation of a space character. In percent-encoding (RFC 3986), each unsafe byte is written as % followed by its two-digit hexadecimal value. Space is ASCII 0x20, hence %20. When you see %20 in a URL, you can safely replace it with a space when displaying the URL to humans. Common codes: %20 = space, %26 = &, %3D = =, %3F = ?, %2F = /, %23 = #.