URL Encoder / Decoder
Encode and decode URLs and URL components safely in your browser.
Input Text
Paste or type a URL or text. Choose an action from the toolbar above.
Output Result
Enter text and select an encoding action from the toolbar to see the result.
How to Encode and Decode URLs
Step-by-Step Guide
- Paste a URL or text. Enter a complete URL or text to encode/decode in the input area.
- Choose an action. Select one of four modes from the toolbar:
- URL Encode — Preserves URL structure (:, /, ?, =, &).
- URL Decode — Reverses percent-encoding.
- Component Encode — Encodes structural characters too; use for query parameter values.
- Component Decode — Decodes component-encoded strings.
- Review the output. The result appears with character, line, and size statistics.
- Copy or download. Use Copy to copy to clipboard or Download to save as a
.txtfile.
URL encoding preserves the structure of a complete URL, while component encoding is intended for individual URL values such as query parameters. All processing happens locally in your browser.
Key Differences
| Function | Use Case | Preserves |
|---|---|---|
encodeURI | Full URLs | :, /, ?, =, &, # |
decodeURI | Full URLs | Same as above |
encodeURIComponent | Query values, path segments | Almost nothing |
decodeURIComponent | Query values, path segments | Same as above |
RFC 3986 & Percent-Encoding
Reserved vs. Unreserved Characters
RFC 3986 defines which characters have special meaning in URLs and must be percent-encoded when used outside their reserved purpose.
// Unreserved characters (never encoded):
// A-Z a-z 0-9 - _ . ~
// Reserved characters (have special meaning):
// : / ? # [ ] @
// ! $ & ' ( ) * + , ; =
// Sub-delimiters (also reserved):
// ! $ & ' ( ) * + , ; =
// Percent-encoding: % + two hex digits
// Space → %20
// " → %22
// < → %3C
// > → %3E
// { → %7B
// } → %7D
// | → %7C
// → %5C
// ^ → %5E
// ` → %60
encodeURI vs encodeURIComponent
The critical difference is which reserved characters are encoded. This determines whether you're encoding a full URL or a single component.
const url = "https://example.com/search?q=hello world&lang=en";
// encodeURI - preserves URL structure
encodeURI(url);
// "https://example.com/search?q=hello%20world&lang=en"
// ^ spaces encoded, but :, /, ?, =, & preserved
// encodeURIComponent - encodes everything
encodeURIComponent("hello world&lang=en");
// "hello%20world%26lang%3Den"
// ^ space, &, = all encoded
// Practical example:
const base = "https://api.example.com/items";
const query = "shoes & socks"; // user input
const fullUrl = base + "?q=" + encodeURIComponent(query);
// "https://api.example.com/items?q=shoes%20%26%20socks"
Unicode & UTF-8 Handling
Both functions encode Unicode characters as UTF-8 byte sequences, then percent-encode each byte.
// Unicode characters become multi-byte UTF-8 sequences
encodeURIComponent("🚀"); // "%F0%9F%9A%80" (4 bytes)
encodeURIComponent("café"); // "caf%C3%A9" (é = 0xC3 0xA9)
encodeURIComponent("Москва"); // "%D0%9C%D0%BE%D1%81%D0%BA%D0%B2%D0%B0"
// Decode reverses the process
decodeURIComponent("%F0%9F%9A%80"); // "🚀"
decodeURIComponent("caf%C3%A9"); // "café"
// Always use encodeURIComponent for user-supplied values
// that go into query strings or path segments
Developer Snippets
JavaScript
Built-in browser APIs for URL encoding and decoding.
// Encode a full URL (preserves structure)
const url = "https://example.com/path?name=John Doe";
encodeURI(url);
// "https://example.com/path?name=John%20Doe"
// Encode a single query value
const query = "John Doe & Jane";
encodeURIComponent(query);
// "John%20Doe%20%26%20Jane"
// Decode
decodeURI("https://example.com/path?name=John%20Doe");
// "https://example.com/path?name=John Doe"
decodeURIComponent("John%20Doe%20%26%20Jane");
// "John Doe & Jane"
// Build a URL safely with URLSearchParams
const params = new URLSearchParams();
params.set("q", "shoes & socks");
params.set("lang", "en");
const url = "https://example.com/search?" + params.toString();
// "https://example.com/search?q=shoes%20%26%20socks&lang=en"
Python
Use urllib.parse for URL encoding in Python.
from urllib.parse import quote, unquote, urlencode
# Quote a single component (like encodeURIComponent)
quote("hello world & stuff")
# 'hello%20world%20%26%20stuff'
# Unquote (like decodeURIComponent)
unquote("hello%20world%20%26%20stuff")
# 'hello world & stuff'
# Quote a full URL path (like encodeURI)
quote("/path/to/resource", safe="/:")
# '/path/to/resource' (preserves / and :)
# Build query string safely
params = {"q": "shoes & socks", "lang": "en"}
urlencode(params)
# 'q=shoes+%26+socks&lang=en'
# For spaces as %20 instead of +, use doseq=True or quote_plus alternative
from urllib.parse import quote_plus
quote_plus("hello world") # 'hello+world' (form encoding)
quote("hello world") # 'hello%20world' (URL encoding)
cURL
Pass pre-encoded URLs or use --data-urlencode for automatic encoding.
# Pass pre-encoded URL
curl "https://api.example.com/search?q=shoes%20%26%20socks"
# Let curl encode query parameters (form-style)
curl --data-urlencode "q=shoes & socks" --data-urlencode "lang=en" "https://api.example.com/search"
# POSTs: q=shoes+%26+socks&lang=en
# GET request with encoded params
curl -G --data-urlencode "q=shoes & socks" --data-urlencode "lang=en" "https://api.example.com/search"
# GETs: https://api.example.com/search?q=shoes+%26+socks&lang=en
# For strict %20 (not +), use jq or printf to pre-encode
curl "https://api.example.com/search?q=$(printf '%s' 'shoes & socks' | jq -sRr @uri)"
# "https://api.example.com/search?q=shoes%20%26%20socks"
Frequently Asked Questions
- URL encoding converts characters into a format that can be transmitted over the Internet. Unsafe ASCII characters are replaced with a "%" followed by two hexadecimal digits.
- URL decoding reverses percent‑encoding, turning %XX sequences back into their original characters.
- URL encoding (encodeURI) leaves characters that are part of the URL structure — such as :, /, ?, =, & — untouched. Component encoding (encodeURIComponent) also encodes those structural characters, making it suitable for encoding a single query‑string value.
- Use component encoding when you are encoding a value that will be placed inside a URL, e.g. a query parameter value. It ensures characters like &, =, and spaces do not break the surrounding URL.
- Yes. The browser's encodeURI / encodeURIComponent functions encode Unicode characters as UTF‑8 byte sequences, then percent‑encode each byte.
- Decoding fails when the input contains malformed percent‑sequences (e.g. "%GG" or an incomplete "%E2") or invalid UTF‑8 byte sequences. The tool will show a friendly error message.
- No. All processing happens entirely in your browser. Your data never leaves your device.
Use Cases
Web developers rely on URL encoding to transmit query parameters that contain spaces, ampersands, non-ASCII characters, or reserved symbols without breaking HTTP requests. Encoding converts these characters into a percent-encoded format that travels safely through proxies, firewalls, and browsers, while decoding restores the original plaintext for debugging server logs, analytics payloads, and application routing. Common scenarios include preparing form submissions, building API endpoints, sharing deep links, and handling redirect URLs that must survive multiple hops. Security teams also use encoding and decoding to inspect obfuscated payloads and verify that user-supplied input does not hide malicious scripts behind percent-encoded characters.
Content managers encode campaign URLs with UTM parameters so tracking tags remain intact across email newsletters and social posts. Mobile developers encode deep-link destinations before handing them to push notification services, and backend engineers encode authentication tokens and callback URLs inside OAuth flows. Any time a string crosses the boundary between a user interface and a network request, encoding prevents silent data loss caused by misinterpreted delimiters.
How-To
Open the URL Encoder / Decoder tool and paste your raw text or full URL into the input field. Select Encode to convert reserved characters into their percent-encoded equivalents, making the string safe for transmission across the web. Select Decode to reverse the process and reveal the original plaintext behind an encoded link. Copy the result with one click and paste it directly into your browser address bar, HTTP client, or backend code without manual editing.
- Open the URL Encoder / Decoder tool in your browser.
- Enter plain text or a complete URL in the input box.
- Click Encode to turn spaces and symbols into percent-encoded characters.
- Click Decode on an encoded string to restore readable text.
- Copy the output and paste it into your request, link, or code.
Regular encoding keeps query strings valid across every browser and server stack, while fast decoding helps you audit links, troubleshoot broken redirects, and verify parameter integrity in minutes instead of hours.
Bookmarking the encoder means you never have to hand-encode strings by hand or memorize the percent-encoding table for every reserved character. The tool handles edge cases such as Unicode emoji, international domain names, and nested query strings automatically, so you can ship links that work the first time in production and staging alike.
Using a dedicated encoder also removes guesswork from code reviews, since teammates can paste encoded values and confirm they match the expected format before merging pull requests that touch routing or integration logic.