URL Encoder / Decoder
Percent-encode and decode URLs and URI components instantly. Supports encodeURIComponent and encodeURI per RFC 3986. 100% client-side.
0 chars
0 chars
About URL Encoding
URL encoding — also called percent-encoding — is defined in RFC 3986 (Uniform Resource Identifier: Generic Syntax). It is the mechanism that lets a URL safely carry characters that would otherwise be illegal, ambiguous, or have structural meaning. Whenever you put user input, search terms, file names, or non-ASCII text into a URL, you almost certainly need to URL-encode it first.
The encoding scheme is simple: take the byte value of each unsafe character, write it in hexadecimal, and prepend a %. A space (byte 0x20) becomes %20. The at sign @ (byte 0x40) becomes %40. Multi-byte UTF-8 characters get encoded one byte at a time, so the rocket emoji 🚀 (U+1F680) becomes %F0%9F%9A%80.
encodeURIComponent vs encodeURI
JavaScript ships with two built-in functions that handle URL encoding, and choosing between them is the most common source of bugs:
- encodeURIComponent encodes everything that is not an unreserved character, including reserved delimiters like
/ ? # & = +. Use it when encoding individual pieces of a URL — a query string value, a path segment, a form field. - encodeURI assumes the input is already a complete URL and leaves the structural delimiters alone. Use it when encoding a fully-formed URL that just happens to contain a few characters that need escaping (like spaces or non-ASCII letters).
A practical example: building a search URL with the term a&b=c. With encodeURIComponent('a&b=c') you get a%26b%3Dc, which is correct because the & and = are part of the value, not delimiters. With encodeURI, those characters would be left as-is and the receiving server would parse them as additional query parameters — a real-world bug that breaks search analytics.
Common Pitfalls
Double-encoding is the most frequent mistake. If a value is already URL-encoded and you encode it again, %20 becomes %2520 and the receiver sees a literal %20 instead of a space. Always know whether your input is plain or already encoded.
Plus signs in query strings are a legacy quirk. The application/x-www-form-urlencoded format used by HTML forms encodes spaces as + instead of %20. Both representations decode to a space in query strings on most servers, but a literal plus character must be encoded as %2B to survive round-tripping.
Hash fragments and slashes behave differently in different libraries. encodeURIComponent escapes /, but most servers and browsers treat unescaped slashes inside a query string as harmless. If you are building deep paths, prefer encodeURI on the full URL or build path segments individually with encodeURIComponent and join them with literal slashes.
Code Examples
Here is how URL encoding looks across common languages, all producing identical output:
// JavaScript
encodeURIComponent('hello world & more')
// → "hello%20world%20%26%20more"
// Python 3
from urllib.parse import quote
quote('hello world & more', safe='')
# → 'hello%20world%20%26%20more'
// Go
import "net/url"
url.QueryEscape("hello world & more")
// → "hello+world+%26+more" (note: + for space, x-www-form-urlencoded style)
// Ruby
require 'cgi'
CGI.escape('hello world & more')
# → "hello+world+%26+more"When to Encode
Encode whenever user-controlled or non-ASCII text is concatenated into a URL: search terms, redirect destinations, OAuth state values, signed token parameters, file names being downloaded, and analytics tracking parameters. Failing to encode is one of the leading causes of broken share links, mis-attributed clicks, and accidentally truncated query strings — and in some cases it can become a security issue if user input breaks out of an expected URL component into a different one.
Frequently Asked Questions
What is URL encoding?
URL encoding (percent-encoding) replaces characters that have special meaning or are not allowed in URLs with a percent sign followed by two hex digits, as defined by RFC 3986. For example, a space becomes %20 and @ becomes %40 inside a query string. This is required so URLs can be transmitted safely across systems that interpret characters differently.
When should I use encodeURIComponent vs encodeURI?
Use encodeURIComponent for individual pieces of a URL — query string values, path segments, form data. It encodes reserved characters like &, =, ?, #, and /. Use encodeURI on a complete URL when you only want to encode characters that are strictly illegal, leaving structural delimiters alone. For most application code, encodeURIComponent is the safer default.
Is double-encoding a problem?
Yes. Encoding an already-encoded string turns %20 into %2520, which breaks the receiving system. Always check whether a string is already encoded before encoding again. A common bug: a backend stores values URL-encoded, then a frontend re-encodes them, producing garbled output. The fix is to decode first, then re-encode only if needed.
What characters are safe in URLs without encoding?
Per RFC 3986, the unreserved characters are letters (A–Z, a–z), digits (0–9), hyphen (-), period (.), underscore (_), and tilde (~). Everything else should be considered for percent-encoding when it appears inside a URI component. Reserved characters like /, ?, #, &, and = have structural meaning and must be encoded when used as values rather than delimiters.
Does URL encoding handle Unicode and emoji?
Yes. encodeURIComponent converts the input to UTF-8 bytes first, then percent-encodes each byte. So a rocket emoji becomes %F0%9F%9A%80 (4 bytes). This is the modern web standard. Older systems sometimes used Windows-1252 or other legacy encodings, which is why some old URLs show garbled characters when re-decoded as UTF-8.
Is my data sent to a server?
No. BytePane runs the entire operation in your browser using built-in JavaScript (encodeURIComponent, decodeURIComponent, encodeURI, decodeURI). You can verify in DevTools — no network requests are made when you encode or decode. This makes the tool safe for tokens, internal URLs, and other sensitive strings.
What does the + sign mean in URLs?
In the application/x-www-form-urlencoded variant used by HTML form submissions, a literal space is encoded as + instead of %20. Inside a query string, both + and %20 typically mean a space. To represent a literal plus character in a query string value, use %2B. This tool follows the RFC 3986 percent-encoding rules and uses %20 for spaces.