URL Encoder & Decoder Free Online
Free online URL encoder and decoder. Encode special characters for use in URLs or decode percent-encoded strings instantly.
URLs can only safely contain a restricted set of ASCII characters - letters, digits, and a small number of reserved characters. When a URL needs to include spaces, special characters, non-ASCII letters, emoji, or any other character outside that safe set, those characters must be percent-encoded (also called URL encoding or URI encoding) before they can be used in a URL. This free URL encoder and decoder converts any text to its percent-encoded form or decodes a percent-encoded URL back to readable text, instantly in your browser.
How to Use the URL Encoder & Decoder
Paste your text or URL
Type or paste the text or URL you want to process into the input field. For encoding, paste the raw text that contains spaces or special characters. For decoding, paste the percent-encoded string (which will contain % signs followed by hexadecimal pairs like %20 for a space or %3A for a colon).
Click Encode or Decode
Click Encode to convert all special and non-ASCII characters to their percent-encoded equivalents. Click Decode to convert percent-encoded sequences back to their original characters. The result appears instantly in the output panel.
Copy and use the result
Click Copy to copy the encoded or decoded URL to your clipboard. Use the encoded URL in API requests, query parameters, href attributes, redirect URIs, or any other context where URLs are used. Use the decoded URL for human-readable display or debugging.
What Is URL Encoding and Why Is It Needed?
The URL specification (RFC 3986) defines a set of "unreserved characters" that can appear in a URL without any encoding: A-Z, a-z, 0-9, hyphen (-), underscore (_), period (.), and tilde (~). All other characters - including spaces, ampersands, equals signs, question marks, slashes (in certain contexts), and non-ASCII characters - must be encoded.
URL encoding works by replacing each character that needs encoding with a % sign followed by two hexadecimal digits representing the character's ASCII (or UTF-8) byte value. A space becomes %20, an ampersand becomes %26, an equals sign becomes %3D, a colon becomes %3A, a forward slash becomes %2F, and a question mark becomes %3F. For non-ASCII characters like é, the character is first encoded as UTF-8 bytes and then each byte is percent-encoded - é becomes %C3%A9.
Common Use Cases for URL Encoding
Search query parameters - when you type a search query into a form, the browser URL-encodes the query before submitting it. "Hello World" becomes "Hello%20World" or "Hello+World" in the URL. Any spaces, symbols, or international characters in search queries are encoded automatically by the browser.
API request parameters - when building API requests programmatically, query parameters must be URL-encoded. If you pass an email address like user@example.com as a query parameter, the @ sign must be encoded as %40: /api/users?email=user%40example.com. If unencoded, the @ might be misinterpreted by the server.
Redirect URIs in OAuth - when implementing OAuth authentication (signing in with Google, GitHub, etc.), the redirect_uri parameter in the OAuth request must be URL-encoded. If the redirect URI contains query parameters itself, those add extra encoding complexity that this tool handles automatically.
File names in URLs - if a file or page name contains spaces or special characters, the URL must encode them. A file named "My Report 2024.pdf" becomes "My%20Report%202024.pdf" in a URL.
Debugging API responses - when you receive a URL or query string that contains percent-encoded sequences, decoding it helps you read the actual content. This tool decodes any percent-encoded URL back to human-readable form for inspection.
encodeURI vs encodeURIComponent
In JavaScript (and conceptually in URL encoding generally), there are two levels of URL encoding:
encodeURI encodes a complete URL while preserving the structural characters that have special meaning in URLs - the colon (:), slash (/), question mark (?), ampersand (&), equals sign (=), and hash (#) are NOT encoded because they are part of the URL structure. Use encodeURI when you have a complete URL that you want to encode for safe use.
encodeURIComponent encodes everything including the structural characters - colons, slashes, ampersands, equals signs, and question marks ARE all encoded. Use encodeURIComponent when encoding a value that will be used as a query parameter value, since the value must not contain unescaped structural characters that would break the URL parsing.
For example: the URL https://example.com/search?q=hello world should be encoded as https://example.com/search?q=hello%20world using encodeURI (preserving the ?, =, and :), while the query value "hello world" would be encoded as "hello%20world" using encodeURIComponent.
Building Safe API Request URLs Programmatically
When constructing API request URLs in code, proper encoding of query parameters is essential to prevent bugs and security vulnerabilities. Here are best practices for different programming contexts:
JavaScript/Node.js - URLSearchParams (recommended):
const params = new URLSearchParams({
email: 'user@example.com',
query: 'search term with spaces',
redirect: 'https://site.com/path?existing=param'
});
const url = `https://api.example.com/search?${params}`;
// https://api.example.com/search?email=user%40example.com&query=search+term...
Python - urllib.parse.urlencode:
from urllib.parse import urlencode, quote_plus
params = {
'email': 'user@example.com',
'query': 'search term with spaces'
}
query_string = urlencode(params, quote_via=quote_plus)
url = f'https://api.example.com/search?{query_string}'
PHP - http_build_query:
$params = [
'email' => 'user@example.com',
'query' => 'search term with spaces'
];
$queryString = http_build_query($params);
$url = 'https://api.example.com/search?' . $queryString;
Common mistake - manual string concatenation: Never build query strings by manually concatenating parameters with & and = without encoding. This creates bugs when parameter values contain special characters and opens security vulnerabilities (URL injection).
OAuth and Redirect URI Encoding
OAuth authentication flows require redirect URIs to be encoded when passed as query parameters. This creates a double-encoding scenario that trips up many developers:
The scenario: Your application's redirect URI is https://yourapp.com/callback?session=abc123. When initiating OAuth with Google or GitHub, you must pass this redirect URI as a parameter in the OAuth request URL.
Correct encoding:
const redirectUri = 'https://yourapp.com/callback?session=abc123';
const encodedRedirect = encodeURIComponent(redirectUri);
const oauthUrl = `https://oauth.provider.com/authorize?client_id=xxx&redirect_uri=${encodedRedirect}`;
// Result: redirect_uri=https%3A%2F%2Fyourapp.com%2Fcallback%3Fsession%3Dabc123
The redirect URI itself contains a query parameter (?session=abc123), so when it becomes a parameter value in the OAuth URL, all its special characters (including the ? and =) must be percent-encoded. This is a common source of OAuth errors - if the redirect URI is not correctly encoded, the OAuth provider will reject it or misinterpret it.
URL Encoding in Different Contexts - HTML, JavaScript, and HTTP
URL encoding requirements differ slightly depending on context:
In HTML anchor href attributes: Browsers automatically encode most special characters when users click links, but & ampersands in query strings must be written as & in the HTML source to avoid HTML parsing issues. Example: <a href="/search?q=hello&lang=en">Search</a> (the HTML shows & but the browser sends & in the actual request).
In JavaScript strings for fetch/XHR: Use encodeURIComponent for parameter values and construct the full URL programmatically. Never paste user input directly into URL strings - always encode it first.
In HTTP headers (Location, Referer): URLs in HTTP headers must be percent-encoded. The Location header for redirects especially must have a properly encoded URL.
In form data (application/x-www-form-urlencoded): Form submissions encode data using URL encoding rules, but spaces become + instead of %20 (a convention from the HTML form specification). Modern APIs should accept both, but be aware that + and %20 are both valid space representations in query strings.
Debugging URL Encoding Issues
When URLs are not working as expected, encoding problems are a frequent cause. Here is how to debug them:
Symptom: 404 Not Found errors despite the path appearing correct. Check if spaces or special characters in the URL are not encoded. A space in a URL path without %20 encoding will break the URL.
Symptom: Query parameters are not received by the API. Check if & ampersands separating parameters are correctly placed and not double-encoded. Also verify that = signs are not encoded when they are parameter separators (they should only be encoded inside parameter values).
Symptom: OAuth redirect_uri mismatch errors. The redirect URI sent in the OAuth request must exactly match the one registered with the OAuth provider. Even a difference in encoding (https://site.com/callback vs https://site.com/callback/) will cause a mismatch.
Symptom: International characters display as garbage. Ensure the URL is UTF-8 encoded before percent-encoding. For example, the Japanese character 日 should become %E6%97%A5 (its UTF-8 byte sequence), not a different encoding.
Tool for debugging: Use this decoder to decode percent-encoded URLs back to readable form. Compare the decoded result to what you expected - discrepancies reveal encoding errors.
Frequently Asked Questions
Related Tools
Base64 Encoder
Encode text and data to Base64 format for safe transmission in URLs and APIs
Hash Generator
Generate MD5, SHA-1, SHA-256, and SHA-512 hashes for data integrity verification
JSON Formatter
Format, validate, and beautify JSON data for debugging APIs and configuration files
JWT Decoder
Decode and inspect JSON Web Tokens used in authentication and authorization