URL Encoder/Decoder
Complete URL encoding and decoding solution with support for both component and full URL encoding modes. Essential for web developers working with APIs, forms, and query parameters.
Full URL: For complete URLs (preserves :, /, ?, # characters)
Text/URL Input (Encode)
URL Encoded Output
URL Encoded Input (Decode)
Decoded Text Output
URL Encoding Explained
URL encoding converts characters into a format that can be transmitted over the Internet by replacing unsafe ASCII characters with % followed by hex digits.
When to use:
Key Features
What is URL Encoding?
URL encoding, also known as percent-encoding, is a mechanism for encoding information in a Uniform Resource Identifier (URI) under certain circumstances. It converts characters into a format that can be transmitted over the Internet safely by replacing unsafe ASCII characters with a "%" followed by two hexadecimal digits.
The encoding process transforms characters that have special meanings in URLs (like spaces, ampersands, and slashes) into a safe format. For example, a space character becomes "%20", and a plus sign becomes "%2B".
URL encoding is essential for:
- Web Forms: Safely transmitting form data with special characters
- Query Parameters: Including spaces, symbols, and non-ASCII characters in URLs
- API Requests: Encoding data for HTTP requests and responses
- File Paths: Handling special characters in file names and paths
- International Characters: Supporting Unicode characters in web addresses
Component vs Full URL Encoding
Component Encoding (encodeURIComponent)
Encodes all characters except: A-Z a-z 0-9 - _ . ! ~ * ' ( )
Use for: Query parameters, form data, individual URI components
Example: "Hello World!" → "Hello%20World%21"
Full URL Encoding (encodeURI)
Encodes fewer characters, preserving URI structure characters like : / ? # [ ] @
Use for: Complete URLs, when you want to preserve the URL structure
Example: "https://example.com/path with spaces" → "https://example.com/path%20with%20spaces"
Practical Use Cases
API Development
When building REST APIs, encode query parameters to handle special characters safely. For example, searching for "C++ programming" in an API call:
GET /api/search?q=C%2B%2B%20programming
Form Submissions
HTML forms automatically URL-encode data, but when constructing URLs manually or working with complex form data, proper encoding prevents data corruption.
Email Links
Create safe mailto links with subjects containing special characters:
<a href="mailto:?subject=Hello%20World%21">Send Email</a>
File Downloads
Generate download links for files with special characters in their names, ensuring browsers can properly handle the file names.
Frequently Asked Questions (FAQ)
- When should I use encodeURIComponent vs encodeURI?
-
Use
encodeURIComponent
for individual components like query parameters or form data. UseencodeURI
when you have a complete URL that you want to encode while preserving its structure. - Why do spaces become %20 instead of +?
-
The
%20
encoding is the standard URL encoding for spaces as defined in RFC 3986. The+
encoding is a non-standard convention used in some older systems for form encoding, but URL encoding always uses%20
. - Can I encode emojis and Unicode characters?
-
Yes, this tool supports Unicode characters. Emojis and international characters are properly encoded using UTF-8 byte sequences. For example, "🚀" becomes "%F0%9F%9A%80".
- What characters don't need to be encoded?
-
In component encoding: A-Z, a-z, 0-9, and symbols - _ . ! ~ * ' ( ). In full URL encoding, additional characters like : / ? # [ ] @ are also preserved.
- Is URL encoding reversible?
-
Yes, URL encoding is fully reversible. You can decode any properly encoded URL back to its original form using decodeURIComponent or decodeURI.
- What happens if I double-encode a string?
-
Double-encoding can cause issues. For example, encoding "%20" (encoded space) again becomes "%2520". Always decode first if you're unsure about the encoding state of your data.
Technical Details
This tool implements the standard URL encoding as specified in RFC 3986. The encoding uses UTF-8 as the character encoding standard, ensuring proper handling of international characters.
Encoding Rules:
- ASCII alphanumeric characters (A-Z, a-z, 0-9) remain unchanged
- Reserved characters (- _ . ! ~ * ' ( )) are preserved in component encoding
- All other characters are percent-encoded as %XX where XX is the hexadecimal representation
- Unicode characters are UTF-8 encoded before percent-encoding