URL Encoder Decoder
Encode and decode URLs and URL components online
Encode and decode URLs and URL components using encodeURIComponent/decodeURIComponent and encodeURI/decodeURI functions.
Input
Output
Input
Output
What is URL Encoder Decoder?
URL Encoder Decoder is a free online tool for encoding and decoding URLs and URL components. This tool helps you convert special characters in URLs to their percent-encoded equivalents and vice versa, ensuring that URLs are properly formatted and can be safely transmitted over the internet.
When building web applications, working with APIs, or handling URLs with special characters, you often need to encode or decode URL strings. This tool makes it easy to perform both operations instantly.
How to use URL Encoder Decoder?
The tool provides two modes of operation:
Encode/Decode Component
Use this mode for encoding/decoding URL components like query parameters, path segments, or individual values:
- Paste your text into the input area.
- Click "Encode Component" to encode using
encodeURIComponent()- this encodes all special characters except:A-Z a-z 0-9 - _ . ! ~ * ' ( ) - Click "Decode Component" to decode percent-encoded text back to its original form.
- Use the Copy button to copy the result.
Encode/Decode Full URL
Use this mode for encoding/decoding complete URLs:
- Paste your URL into the input area.
- Click "Encode URL" to encode using
encodeURI()- this preserves URL structure characters like:,/,?,&,= - Click "Decode URL" to decode the URL.
- Use the Copy button to copy the result.
Features
- Two encoding methods - Choose between component encoding and full URL encoding
- Bidirectional conversion - Encode and decode in both directions
- Error handling - Clear error messages for invalid input
- Instant results - See results immediately as you encode/decode
- Copy functionality - Easy copy to clipboard
- Browser-based - All processing happens locally
- Free to use - No registration required
Understanding URL Encoding
What is URL Encoding?
URL encoding converts characters into a format that can be transmitted over the internet. Special characters are replaced with a percent sign (%) followed by two hexadecimal digits representing the character's ASCII code.
Why is URL Encoding Needed?
- Special characters - URLs can only contain certain characters from the ASCII set
- Reserved characters - Characters like
?,&,=have special meaning in URLs - Safety - Ensures URLs work correctly across all browsers and systems
- Data transmission - Allows passing any text data through URLs
Common Encoded Characters
| Character | Encoded | Description |
|---|---|---|
| Space | %20 | Space character |
! | %21 | Exclamation mark |
" | %22 | Double quote |
# | %23 | Hash/pound sign |
$ | %24 | Dollar sign |
% | %25 | Percent sign |
& | %26 | Ampersand |
+ | %2B | Plus sign |
, | %2C | Comma |
/ | %2F | Forward slash (in components) |
: | %3A | Colon (in components) |
; | %3B | Semicolon |
= | %3D | Equals sign (in components) |
? | %3F | Question mark (in components) |
@ | %40 | At symbol |
Difference Between encodeURI and encodeURIComponent
encodeURI()
Use for: Encoding complete URLs
Preserves: : / ? # [ ] @ ! $ & ' ( ) * + , ; =
Example:
Input: https://example.com/search?q=hello world
Output: https://example.com/search?q=hello%20worldencodeURIComponent()
Use for: Encoding URL components (parameters, values, path segments)
Encodes: All characters except: A-Z a-z 0-9 - _ . ! ~ * ' ( )
Example:
Input: hello world & goodbye
Output: hello%20world%20%26%20goodbyeUse Cases
1. Query Parameters
Encode values before adding them to URL query strings:
Input:
search query with spacesEncoded (Component):
search%20query%20with%20spacesUsage:
https://example.com/search?q=search%20query%20with%20spaces2. API Requests
Encode parameters for API calls:
Input:
Encoded:
user%40example.com3. URL Path Segments
Encode file names or path segments with special characters:
Input:
My Document (Final).pdfEncoded:
My%20Document%20%28Final%29.pdf4. Social Media Sharing
Encode URLs for social media sharing:
Input:
https://example.com/article?title=Hello World&author=John DoeEncoded:
https://example.com/article?title=Hello%20World&author=John%20Doe5. Form Data
Encode form data before submission:
Input:
name=John & MaryEncoded:
name%3DJohn%20%26%20MaryExamples
Example 1: Encoding Query Parameters
Input:
name=John Doe&[email protected]Output (encodeURIComponent):
name%3DJohn%20Doe%26email%3Djohn%40example.comExample 2: Encoding Full URL
Input:
https://example.com/search?q=javascript tutorialOutput (encodeURI):
https://example.com/search?q=javascript%20tutorialExample 3: Special Characters
Input:
Hello World! #coding @2024Output (encodeURIComponent):
Hello%20World!%20%23coding%20%402024Example 4: Decoding
Input:
Hello%20World%21%20How%20are%20you%3FOutput (decode):
Hello World! How are you?Tips for Best Results
-
Choose the right method:
- Use Component encoding for query parameters, form data, or individual values
- Use Full URL encoding when encoding an entire URL
-
Multiple encoding: Avoid encoding the same string multiple times, as it will produce incorrect results
-
Testing: Always test your encoded URLs in a browser to ensure they work correctly
-
Reserved characters: Remember that
encodeURI()preserves URL structure characters -
Plus sign: In URL encoding,
+can represent a space, butencodeURIComponentconverts it to%2B
Common Issues and Solutions
Issue: Encoded URL doesn't work in the browser
Solution: Make sure you're using the correct encoding method. Use encodeURI() for complete URLs.
Issue: Getting "Invalid URL encoded string" error
Solution: The input may not be properly encoded or may contain invalid sequences. Check for incomplete percent encoding (e.g., %2 without the second digit).
Issue: Spaces encoded as + instead of %20
Solution: The + sign is a valid space representation in query strings, but our tool uses %20. Both are correct and interchangeable in URLs.
Issue: Special characters not encoding
Solution: Make sure you're using Component encoding for individual values, not Full URL encoding.
Frequently Asked Questions
Q: What's the difference between encodeURI and encodeURIComponent?
A: encodeURI() is designed for encoding complete URLs and preserves URL structure characters like :, /, ?, &. encodeURIComponent() is for encoding individual components and encodes almost everything, including URL structure characters.
Q: Can I encode non-English characters?
A: Yes! The tool handles Unicode characters (Chinese, Arabic, emoji, etc.) and converts them to their percent-encoded UTF-8 representation.
Q: Is this tool safe to use with sensitive data?
A: Yes, all encoding and decoding happens entirely in your browser. No data is sent to any server.
Q: Why do I see %20 instead of + for spaces?
A: Both are valid in URLs. %20 is the standard percent-encoding, while + is specifically for form data. Modern applications typically use %20.
Q: Can I encode an entire HTML document?
A: Yes, but be aware that encoding large texts will produce very long results. This tool is best for URLs and smaller text snippets.
Q: What happens if I encode already encoded text?
A: It will be double-encoded. For example, %20 becomes %2520. Use the decode function first if you're unsure.
Privacy & Security
Your privacy is important to us:
- No data is sent to any server
- All processing happens in your browser
- No cookies or tracking
- No account or login required
- Completely free to use
Related Tools
Comments