URL Encode / Decode Tool
Instantly encode and decode URLs, query strings, special characters, and web-safe text directly in your browser with real-time conversion.
Encodes all special characters except: A–Z a–z 0–9 - _ . ! ~ * ' ( )
Related Developer Tools
More utility tools from SamCalculator for developers, security professionals, and power users.
- Word CounterCount words, check readability, and analyze your writing in real-time.
- Password GeneratorGenerate strong, secure passwords with custom length and complexity.
- IP Subnet CalculatorCalculate IPv4 and IPv6 subnets, CIDR ranges, and VLSM allocations.
- Barcode Scanner ToolScan QR codes, UPC, EAN, ISBN, and 12+ barcode formats from camera or images.
- Password Strength CheckerCheck password strength, entropy, crack time, and breach risk.
What Is URL Encoding?
URL encoding, formally called percent encoding, is the process of converting characters that are unsafe or reserved in a URL into a format that can be safely transmitted over the internet. Every character that falls outside the set of unreserved characters — letters, digits, hyphens, underscores, dots, and tildes — must be replaced with a percent sign followed by its two-digit hexadecimal UTF-8 code. A space, for example, becomes %20; the Euro sign becomes %E2%82%AC.
URL decoding is the reverse: converting those %XX sequences back into their original characters. Both operations happen constantly in modern web development — every form submission, every API call, every search query. This tool performs both operations instantly in your browser, with zero data sent to any server.
How URL Encoding Works
The Encoding Step
Each character is first converted to its UTF-8 byte representation. Each byte is then written as a percent sign followed by the two uppercase hexadecimal digits of that byte value. A multi-byte character like é (U+00E9) produces two bytes — 0xC3 and 0xA9 — yielding %C3%A9.
The Decoding Step
Each %XX sequence is interpreted as a hexadecimal byte value. Consecutive sequences belonging to a single multi-byte character are grouped and decoded together using UTF-8 to recover the original Unicode code point. If any sequence is malformed (incomplete or non-hex), decoding fails gracefully with an error message.
Reserved vs Unreserved
RFC 3986 splits URL characters into reserved characters that have structural meaning (: / ? # [ ] @ ! $ & ' ( ) * + , ; =) and unreserved characters that are always safe (A–Z a–z 0–9 - _ . ~). Reserved characters must be encoded when they appear inside a value, not as structure.
encodeURI vs encodeURIComponent
encodeURI() encodes a complete URL and preserves structural characters like :/?#. encodeURIComponent() encodes everything except unreserved characters — ideal for encoding individual query parameter values before concatenating them into a URL.
6 Ways Developers Use URL Encoding
Building API Requests
Encode query parameter values before appending them to endpoint URLs. Never trust raw user input directly in a URL — spaces and special characters will break the request.
Form Submission
HTML forms with method GET encode the form data as application/x-www-form-urlencoded, replacing spaces with + and encoding reserved characters before appending to the URL.
Sharing Deep Links
When building share URLs that include dynamic content (search terms, filter states, coordinates), encode the payload so it survives copy-paste, email clients, and social-media link shorteners.
OAuth & JWT Tokens
Access tokens, ID tokens, and PKCE code challenges often contain +, /, and = characters from base64. Encode them with encodeURIComponent before placing in a redirect URI.
Webhook Payloads
Webhook callback URLs frequently include encoded event metadata or replay tokens. Decode them server-side before parsing to avoid off-by-one errors in signature verification.
SEO-Safe Slugs
Non-Latin characters in URL paths (Arabic, Chinese, emoji) must be percent-encoded for full HTTP compatibility. Encoding ensures the slug survives all intermediaries and reverse proxies.
URL Encoding Best Practices
- Always use encodeURIComponent() on individual query parameter values, never on the full URL.
- Encode data before inserting it into a URL — not after — to prevent double-encoding bugs.
- Never encode the structural delimiters (?, &, =, /) that separate URL components.
- Use the + shorthand for spaces only inside query strings — never inside the path.
- Prefer uppercase hex digits in percent sequences for strict RFC 3986 compliance (e.g. %2F not %2f).
- Always decode received URL parameters before using them in database queries or file paths.
Why URL Encoding Matters for Security
Improper URL encoding is not just a compatibility issue — it is a security vulnerability. Missing or double encoding can enable path traversal attacks (%2F → /), open redirect exploits, and SSRF (Server-Side Request Forgery). OWASP lists improper URL handling in the top ten web application risks.
On the SEO side, canonicalization inconsistencies caused by mixed encoded and decoded characters in URLs can lead Google to treat the same page as duplicates, splitting PageRank and diluting rankings. Consistent, correct encoding is a foundational technical-SEO requirement.
Tricky Encoding Edge Cases
Double Encoding
Encoding an already-encoded string converts % into %25, turning %20 into %2520. Always check whether your input is already encoded before processing.
The + vs %20 Trap
In query strings, + is widely interpreted as a space. But in URL paths, + is a literal plus sign — only %20 means space. Using + in a path will confuse servers and proxies.
Emoji in URLs
Emoji encode to multi-byte UTF-8, producing long sequences (🚀 = %F0%9F%9A%80). Many link-shorteners and email clients silently truncate URLs at unusual byte boundaries — keep emoji out of paths.
IDN Hostnames
Internationalized domain names like münchen.de are encoded using Punycode (xn--mnchen-3ya.de), not percent-encoding. Do not percent-encode the hostname — only the path and query components.
Fragment Encoding
The URL fragment (#section) is processed by the browser only — it is never sent to the server. Encoding issues in fragments typically break client-side anchor navigation rather than server-side routing.
Core Encoding Rules
| Method | Preserves | Encodes | Best For |
|---|---|---|---|
| encodeURI() | : / ? # [ ] @ ! $ & ' ( ) * + , ; = ~ - _ . | Spaces, non-ASCII, control chars | Full URLs |
| encodeURIComponent() | A–Z a–z 0–9 - _ . ! ~ * ' ( ) | All reserved chars, spaces, non-ASCII | Query values, path segments |
| RFC 3986 Strict | A–Z a–z 0–9 - _ . ~ | Everything else, including ! ' ( ) * | OAuth, JWT, strict APIs |
| Query String (+ spaces) | A–Z a–z 0–9 - _ . ! ~ * ' ( ) | Reserved chars; spaces become + | HTML form GET submissions |
| Form Data | A–Z a–z 0–9 - _ . ~ | All reserved chars; spaces become + | HTML form POST, fetch body |
Common URL Encoding Mistakes
Mistake
Encoding the full URL with encodeURIComponent()
Fix: Only use encodeURIComponent() on individual values — it will destroy the : and // in the protocol.
Mistake
Forgetting to encode square brackets [ ]
Fix: RFC 3986 reserves [ ] for IPv6 literals only. In query values, encode them as %5B and %5D.
Mistake
Using + for spaces in URL paths
Fix: Paths only recognize %20 as a space. The + symbol is literal in path context — only use + in query strings.
Mistake
Not encoding & inside attribute values
Fix: In HTML attributes, & must be & and query strings must be fully encoded before embedding in href.
Mistake
Double-decoding user input on the server
Fix: Decode exactly once. Decoding twice can let attackers sneak in %2500 → %00 → null byte injections.
Mistake
Assuming ASCII-only URLs are safe
Fix: Many browsers silently encode non-ASCII path characters differently. Always encode explicitly rather than relying on browser behavior.
100% Private — No Data Leaves Your Browser
Every encoding and decoding operation in this tool is performed using the JavaScript encodeURIComponent, decodeURIComponent, and URL APIs built directly into your browser. No text, URL, or API key you enter here is ever transmitted to SamCalculator servers or any third party. Your data is processed locally and disappears when you close the tab.