URL Encoder/Decoder
Online URL Encoding and Decoding Conversion Tool,Supports batch processing
Encoding Instructions
encodeURIComponent:Encode everything except letters、numbers、(、)、.、!、~、*、'、-and_all other characters。suitable for encodingURLparameters。
encodeURI:Encode except forURLall characters except those with special meaning。suitable for encoding completeURL。
URL Encoding Guide
Learn when and how to properly encode URLs and query parameters.
When Do You Need URL Encoding?
- Query Parameters:
- Special characters in search terms
- Spaces in parameter values
- Non-ASCII characters in URLs
- Common Scenarios:
- Building API requests
- Creating dynamic URLs
- Handling form submissions
Which Encoding Function to Use?
- encodeURIComponent: For query parameters and path segments
// Encoding a search query
const query = "cats & dogs";
const url = `https://example.com/search?q=${encodeURIComponent(query)}`;
// Result: https://example.com/search?q=cats%20%26%20dogs
// Encoding a full URL with spaces
const url = encodeURI("https://example.com/path with spaces/");
// Result: https://example.com/path%20with%20spaces/
Best Practices
- API Requests: Always encode parameters separately before combining
- Special Characters: Pay attention to +, &, =, ?, / in URLs
- Unicode: Handle international characters properly
- Testing: Verify both encoding and decoding work as expected