URL Encoder/Decoder

Encode URLs for Safe Transmission

Encode or Decode URL

Why URL Encoding Matters

URL encoding, also known as percent-encoding, converts characters into a format safe for internet transmission. Since URLs only support ASCII, special characters like emojis, spaces, and non-Latin scripts must be encoded. UTF-8 encoding is the standard that converts any character into byte sequences, each byte represented as %HH. Without proper encoding, characters like & or = would break query parameter parsing and corrupt URL structure.

Reserved Characters Explained

CharNamePurpose
?Question MarkSeparates path from query
&AmpersandSeparates query parameters
=EqualsName-value separator
/SlashPath segment separator
#HashFragment identifier
%PercentEscape indicator

Characters That Need Encoding

Spaces " " Becomes: %20
Special Characters & ? # = $ + , / : ; Encoded due to reserved meaning
Unicode 你好世界 Encoded as UTF-8 bytes

Safe Characters

Only A-Z, a-z, 0-9, -, _, ., ~ are safe without encoding. All others require percent-encoding using UTF-8.

Common Use Cases

  • Form Submission: Query parameters with special characters
  • API Endpoints: URLs with dynamic path parameters
  • Redirect URLs: Query strings and fragments
  • HTML Links: Safe URL generation

Important Notes

URL encoding differs from Base64 encoding. URL encoding uses percent-encoding (%20 for space), while Base64 uses a different alphabet for binary data.

For query parameters, use encodeURIComponent() to properly encode all special characters including & and =.

Frequently Asked Questions

encodeURI vs encodeURIComponent?Use encodeURI() when preserving /, ?, #. Use encodeURIComponent() for individual query values with any special characters.
Why %20 and not + for spaces?Plus sign encoding is legacy form encoding. Modern URLs use %20 for spaces. Plus only appears in application/x-www-form-urlencoded form data.
How are Unicode characters encoded?First converted to UTF-8 bytes, then each byte percent-encoded. 你好 becomes %E4%BD%A0%E5%A5%BD (3 bytes per character).
What happens without encoding?Unencoded special characters break parsing, cause security vulnerabilities like parameter injection, or corrupt data transmission.
Can I decode multiple times?Only if double-encoded. Typically decode once. Double encoding happens when data is encoded, then encoded again as part of another parameter.
Are hex digits case-sensitive?Both %2F and %2f are valid and equivalent. Case-insensitive, though uppercase is conventionally used.