URL Encoder/Decoder

Encode or decode URLs and query strings. Convert special characters to percent-encoded format for safe use in URLs.

Common URL Encodings

%20 or +

!

%21

#

%23

$

%24

&

%26

'

%27

(

%28

)

%29

*

%2A

+

%2B

,

%2C

/

%2F

:

%3A

;

%3B

=

%3D

?

%3F

@

%40

[

%5B

]

%5D

Encoding Methods Explained

Component

encodeURIComponent() - Encodes everything except alphanumeric and - _ . ! ~ * ' ( ). Best for query parameters.

Full URI

encodeURI() - Preserves URL structure characters. Use for complete URLs with path and query.

Form Data

application/x-www-form-urlencoded - Same as Component but spaces become + instead of %20.

What is URL Encoding?

URL encoding, also known as percent-encoding, is a mechanism for encoding information in a Uniform Resource Identifier (URI). It replaces unsafe ASCII characters with a "%" followed by two hexadecimal digits representing the character's ASCII code.

Why Encode URLs?

  • Safety: Reserved characters like &, ?, = have special meaning in URLs
  • Special Characters: Non-ASCII characters must be encoded for compatibility
  • Spaces: URLs cannot contain spaces—they must be encoded as %20 or +
  • API Calls: Query parameters often contain characters that need encoding

Encoding Methods

  • encodeURIComponent: Encodes everything except A-Z, a-z, 0-9, - _ . ! ~ * ' ( )
  • encodeURI: Preserves URL structure characters like : / ? # [ ] @
  • Space as +: Form data encoding where spaces become + instead of %20

Common Use Cases

  • Building API request URLs with query parameters
  • Encoding form data for submission
  • Creating bookmarklets and javascript: URLs
  • Debugging URL-related issues

Frequently Asked Questions

What is URL encoding?
URL encoding, also known as percent-encoding, converts special characters in URLs to a format that can be safely transmitted. Characters like spaces, &, ?, and # are replaced with a % followed by two hexadecimal digits representing their ASCII code. For example, a space becomes %20 or +.
What's the difference between encodeURI and encodeURIComponent?
encodeURI() preserves URL structure characters like : / ? # [ ] @, making it suitable for encoding entire URLs. encodeURIComponent() encodes all special characters, making it suitable for encoding query parameter values. Use encodeURIComponent for user-generated input in URLs.
Why do spaces sometimes encode as + and sometimes %20?
In application/x-www-form-urlencoded format (form data), spaces become + signs. In standard URL encoding (RFC 3986), spaces become %20. Most modern APIs accept both, but query parameters in URLs should use %20.
Is URL encoding reversible?
Yes, URL encoding is fully reversible. Decoding converts %-encoded sequences back to their original characters. The process is deterministic—the same input always produces the same encoded output.
Which characters need to be encoded in URLs?
Characters that must be encoded include: spaces, &, ?, #, /, :, ;, =, @, $, ,, %, <, >, {, }, |, \, ^, ~, [, ], and any non-ASCII characters like é, ñ, or Chinese characters.
What is the maximum length of a URL?
There is no official limit in the URL spec, but browsers limit URLs to around 2,000-8,000 characters. Internet Explorer limits to 2,048 characters. For long data, use POST requests instead of URL parameters. Servers may also impose their own URL length limits.

Related Tools