URL Encoder & Decoder
Encode special characters or decode percent-encoded URLs instantly.
๐ Complete Guide to URL Encoding
URL encoding, also known as percent-encoding, is a fundamental mechanism for safely transmitting data within URLs. Since URLs can only contain a limited subset of ASCII characters, any special characters, spaces, or non-English text must be converted into a format that web servers and browsers can understand. This tool handles both encoding (converting characters to their percent-encoded form) and decoding (converting back to readable text).
Understanding URL encoding is essential for web developers, API integrators, SEO specialists, and anyone who works with web addresses. Incorrectly encoded URLs can lead to broken links, failed API requests, and security vulnerabilities. This encoder/decoder makes the process simple and error-free.
How URL Encoding Works
When a character needs to be encoded, it's converted to its UTF-8 byte representation, and each byte is written as a percent sign followed by two hexadecimal digits. For example, a space character (ASCII 32) becomes %20, and the Euro sign โฌ becomes %E2%82%AC (three bytes in UTF-8).
| Character | Encoded Form | ASCII/Unicode Value | Common Use |
|---|---|---|---|
| (space) | %20 or + | 32 | Separating words in search queries |
| ! | %21 | 33 | Exclamation in text |
| # | %23 | 35 | Fragment identifiers, hashtags |
| $ | %24 | 36 | Currency in prices |
| % | %25 | 37 | Literal percent signs |
| & | %26 | 38 | Parameter separators |
| + | %2B | 43 | Math expressions, phone numbers |
| / | %2F | 47 | Path components with slashes |
| = | %3D | 61 | Values containing equals signs |
| ? | %3F | 63 | Literal question marks in values |
| @ | %40 | 64 | Email addresses, usernames |
Characters That Don't Need Encoding
Not every character requires encoding. The following "unreserved" characters are safe to use directly in URLs:
- Uppercase letters: A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
- Lowercase letters: a b c d e f g h i j k l m n o p q r s t u v w x y z
- Digits: 0 1 2 3 4 5 6 7 8 9
- Special unreserved: - (hyphen), _ (underscore), . (period), ~ (tilde)
When to Use URL Encoding
- Query Parameters: When passing user input or data through URL parameters like ?search=hello%20world
- API Requests: When building RESTful API endpoints with dynamic data in the path or query string
- Form Submissions: GET method forms automatically encode data, but understanding the process helps with debugging
- Special Characters: Whenever your URL contains spaces, symbols, or non-ASCII characters like accents or emojis
- Redirects: When creating redirect URLs that contain other URLs as parameters
- Tracking Links: Marketing URLs often contain encoded parameters for analytics
Encoding Options Explained
| Option | What It Does | When to Use |
|---|---|---|
| Encode Spaces | Converts spaces to %20 | Standard URL encoding for most cases |
| Space as + (Form) | Converts spaces to + instead of %20 | HTML form submissions (application/x-www-form-urlencoded) |
| Encode All Characters | Encodes everything except letters and numbers | Maximum compatibility or when unsure what's safe |
๐ก Pro Tip: In JavaScript, use encodeURIComponent() for encoding query parameter values, and encodeURI() for encoding complete URLs while preserving the URL structure (protocol, slashes, etc.). Never use escape() as it's deprecated and doesn't handle Unicode properly.
Common Encoding Mistakes to Avoid
- Double encoding: Encoding a URL that's already encoded turns %20 into %2520, breaking the link
- Not encoding special characters: Unencoded & or = in parameter values will corrupt your query string
- Encoding the entire URL: Protocol (https://) and path separators (/) should usually not be encoded
- Forgetting to encode +: In query strings, + means space, so literal + must be encoded as %2B
- Platform differences: Some systems use different encoding conventions, always test thoroughly