URL Encoder & Decoder
Encode and decode URL components, full URLs, and Base64 strings. See all encoding formats at once with one-click copy.
About This Tool
The URL Encoder and Decoder is an essential utility for web developers, API engineers, and anyone who works with URLs, query strings, and web-based data transfer. URLs have strict rules about which characters can appear in them, and this tool makes it easy to convert between human-readable text and URL-safe encoded formats. It supports three encoding modes: URL component encoding for query parameter values, full URL encoding for complete URLs, and Base64 encoding for binary-to-text conversion.
How URL Encoding Works
URL encoding, also known as percent-encoding, is defined in RFC 3986 and replaces unsafe characters with a percent sign followed by two hexadecimal digits representing the character's byte value. For example, a space becomes %20, an ampersand becomes %26, and a plus sign becomes %2B. For multi-byte Unicode characters like accented letters or CJK characters, each byte is encoded separately, so a single character might produce multiple %XX sequences. The encoding ensures that every character in the URL is represented using only the ASCII character set, which all internet protocols can reliably transmit.
encodeURIComponent vs encodeURI
JavaScript provides two built-in functions for URL encoding, and choosing the right one is critical. encodeURIComponent encodes every character that is not an unreserved character (letters, digits, -, _, ., ~), making it the correct choice for encoding individual values that will be placed into URL query parameters, path segments, or hash fragments. For example, encoding the value "name=John&age=30" as a parameter value produces "name%3DJohn%26age%3D30", preventing the embedded = and & from being interpreted as URL syntax.
encodeURI is designed for encoding complete URLs and preserves characters that have structural meaning in URLs, including : / ? # [ ] @ ! $ & ' ( ) * + , ; =. Use encodeURI when you have a complete URL that might contain Unicode characters in the path or query and you want to make it ASCII-safe without breaking its structure. For most cases involving form data or API parameters, encodeURIComponent is the correct choice.
Base64 Encoding
Base64 encoding converts arbitrary binary data into a string of 64 printable ASCII characters. While it serves a different purpose than URL encoding, it is frequently used in web development contexts. Data URIs use Base64 to embed images directly in HTML or CSS. JWT (JSON Web Tokens) use Base64url encoding for their header and payload. Basic HTTP authentication encodes the username:password pair in Base64. Email attachments use Base64 in MIME encoding. This tool supports standard Base64 encoding and decoding, handling Unicode text correctly by first encoding to UTF-8 before applying Base64.
Common Pitfalls
One of the most common mistakes is double-encoding: applying URL encoding to text that has already been encoded, turning %20 into %2520. This happens when URL encoding is applied at multiple layers of an application stack, such as in both the application code and a middleware library. Another pitfall is using encodeURI when encodeURIComponent is needed, leaving characters like & and = unencoded in parameter values. A third issue is not encoding the plus sign (+), which represents a space in form-urlencoded data but is a literal plus in other contexts. This tool shows all encoding formats simultaneously so you can choose the correct one for your use case.
Security Considerations
Proper URL encoding is a fundamental security practice. Failing to encode user-supplied data in URLs can lead to injection attacks, including cross-site scripting (XSS) through URL parameters, open redirect vulnerabilities, and server-side request forgery (SSRF). Always encode data that will be inserted into URLs, even if it appears to be safe. Defense in depth requires encoding at the point of insertion, not relying on input validation alone. This tool runs entirely in your browser with no server communication, making it safe for encoding sensitive data like API keys and authentication tokens.
Frequently Asked Questions
What is the difference between encodeURIComponent and encodeURI?
Why do I need to URL-encode strings?
What is Base64 encoding and when should I use it?
How do I decode a URL with multiple encoded layers?
What characters are safe to use in URLs without encoding?
Does this tool send my data to a server?
Was this tool helpful?