URL encoding & decoding FAQ.

42 answers on percent-encoding and decoding in one place — the basics, how to do it in JavaScript, Python, Java, Go and PHP, %20 vs +, double-encoding, garbled characters, SEO, and how these tools handle your data.

The basics

URL encoding — formally percent-encoding, defined in RFC 3986 — converts characters that aren’t safe in a URL into a % followed by their two hexadecimal digits. A space becomes %20, ? becomes %3F, and a non-ASCII character like é becomes its UTF-8 bytes %C3%A9. It lets special characters travel safely inside a URL that only permits a limited ASCII set.

URL decoding — also called percent-decoding — is a mechanism defined in RFC 3986 that reverses URL encoding. It reads the %XX hexadecimal sequences in a string and converts them back into the characters they represent: %20 becomes a space, %3F becomes a question mark. It turns a machine-safe URL back into readable text.

The HTTP request line only allows a limited subset of US-ASCII. If special characters, spaces, or non-English text are placed into a URL raw, intermediate proxies, load balancers, and servers can misread the URL syntax and drop or break the request. Encoding turns those characters into %XX sequences so the URL stays valid end to end.

RFC 3986 sorts characters into two groups. Unreserved characters — A–Z a–z 0–9 - _ . ~ — are always safe and never need encoding. Reserved characters — ? & = : / # and a few others — have structural meaning in a URL, so they must be encoded when they appear inside a value rather than as structure.

Yes — “percent-encoding,” “URL encoding,” and “URL escaping” all describe the same reversible scheme. One caveat: JavaScript’s old escape() / unescape() functions are not the same. They are deprecated and produce non-standard %uXXXX sequences for non-ASCII characters, so use encodeURIComponent / decodeURIComponent instead.

They solve different problems. URL encoding makes a string safe to travel inside a URL — a space becomes %20. HTML encoding makes a string safe to display inside a web page without being read as markup — < becomes &lt;, which helps prevent cross-site scripting. A value used in both places needs each applied in its own context; they aren’t interchangeable.

URL encoding escapes individual unsafe characters as %XX, keeping text mostly readable — best for query values and paths. Base64 converts arbitrary binary data into a continuous stream of 64 safe characters — best for embedding files or binary payloads. One catch: standard Base64 output contains + and /, which still need URL-encoding unless you use the URL-safe “Base64URL” variant.

No. Encoding is a formatting change, not encryption — anyone can reverse a percent-encoded string instantly, so it gives zero confidentiality. Sensitive values belong in the body of an HTTPS POST request, never in a URL, where they end up in browser history, server logs, and referrer headers. Encode for transport safety, not secrecy.

You can, but it’s inefficient. Percent-encoding turns each unsafe byte into three characters (%XX), so in the worst case the output is about three times the input size (roughly +200%). For binary payloads, Base64 or Base64URL is cleaner because it only adds about 33% overhead.

There’s no length limit in the HTTP standard itself, but practical limits exist. A conservative ceiling of around 2,000 characters keeps a URL safe across old browsers and picky infrastructure, though modern browsers and servers handle far more. If you’re approaching that, switch from a GET query string to a POST body — see our troubleshooting guide for the specific server limits (Apache, Nginx, CDNs).

Encoding and decoding in code

Use encodeURIComponent for individual pieces of a URL — a query parameter value, a path segment, or a fragment. It escapes everything that isn't a letter, digit, or one of - _ . ! ~ * ' ( ). Use encodeURI only when encoding a complete URL where you want to preserve the structural characters (: / ? # [ ] @ & =) — but you almost never want this in practice.

Use encodeURIComponent(string) for an individual query value, path segment, or fragment — it escapes structural characters like ? & =. Use encodeURI(string) only for a complete URL, where you want to keep structural tokens like :// and / intact. For building query strings, URLSearchParams is usually the cleanest option.

Use decodeURIComponent(string) for an individual query value, path segment, or fragment. Use decodeURI(string) only for a complete URL where you want to preserve structural characters like : and /. In most cases decodeURIComponent is what you want.

decodeURIComponent() throws this when it hits a broken percent sequence — a % not followed by two valid hex digits (like abc%2), or bytes that don’t form a valid UTF-8 character. Validate or repair the source string before decoding. Pasting it into our decoder shows where the invalid sequence is instead of crashing.

Use the urllib.parse module. urllib.parse.quote(string) percent-encodes a path string; urllib.parse.quote_plus(string) encodes spaces as + for form data; and urllib.parse.urlencode(dict) turns a dictionary of key-value pairs into a full query string in one call.

Use the urllib.parse module. urllib.parse.unquote(string) decodes standard percent-encoding; urllib.parse.unquote_plus(string) also converts + into spaces, which is what you want for form-encoded query strings.

Use java.net.URLEncoder.encode(text, StandardCharsets.UTF_8). Always specify UTF-8 explicitly — omitting the charset lets the platform fall back to an unpredictable system default and distort multi-byte characters. Note URLEncoder follows form-encoding rules, so it encodes spaces as +.

Use java.net.URLDecoder.decode(string, "UTF-8"). Always pass the character encoding explicitly — if you omit it, the platform may fall back to an unpredictable system default and produce garbled output.

Use the net/url package. url.QueryEscape(string) encodes a value for a query string, converting spaces to + per form rules; url.PathEscape(string) encodes a path segment, where a space becomes %20. Pick the one that matches where the value goes.

Use the net/url package. url.QueryUnescape(string) decodes percent-encoding and converts + to spaces (query semantics); url.PathUnescape(string) decodes without the +-to-space conversion, for path segments.

PHP has two functions. rawurlencode($string) follows RFC 3986 and encodes spaces as %20 — use it for path segments. urlencode($string) follows the older form convention and encodes spaces as + — use it for form-style query data. Choosing the wrong one is a common source of +-versus-space bugs.

There’s no single cross-platform SQL function for it. Approaches vary by engine — some teams write a small user-defined function, and PostgreSQL can assemble encoding with string and byte helpers. In practice it’s usually cleaner to encode in your application layer or a tool than inside SQL.

Errors and debugging

Double-encoding is encoding a string that was already encoded, so %20 becomes %2520 (the % itself becomes %25). Prevent it by encoding raw user input once, at the boundary where you build the request — never re-encode a value that’s already part of a URL. To recover a double-encoded value, decode it recursively.

Two different standards. RFC 3986 encodes a space as %20 everywhere in a URL. The separate application/x-www-form-urlencoded convention — defined in the WHATWG URL Standard and used by HTML forms and URLSearchParams — encodes a space as +. %20 is the safer default; reserve + for form bodies.

Because of the form-encoding convention (application/x-www-form-urlencoded), where + means space. If you’re decoding a path segment where + is a literal plus, turn off the “Treat + as space” option before decoding, or your real plus signs will wrongly become spaces.

Running encodeURIComponent over a full URL encodes its structure along with its data, so https://example.com/ turns into https%3A%2F%2Fexample.com%2F — unroutable. Split the URL into parts, encode only the individual dynamic values, then assemble the final URL around them.

That’s a character-set mismatch: the bytes were encoded in one charset (often Windows-1252 or ISO-8859-1) but you’re decoding them as UTF-8. Pick the correct source charset. Our decoder supports 50+ charsets — try Windows-1252 or ISO-8859-1 for legacy Western data, Shift_JIS for old Japanese, GBK for old Chinese, KOI8-R for old Russian.

Percent-encoding operates on bytes, so the charset determines the result. The letter é is one byte in ISO-8859-1 (%E9) but two bytes in UTF-8 (%C3%A9). If the encoder’s charset doesn’t match what the receiver expects, the decoded text comes out garbled. UTF-8 is the modern default and the right choice for almost all new work.

Often a filter or faceted-navigation UI that re-encodes the whole query string on every click. Each pass turns % into %25, so a value balloons (%253A → %25253A → …) until it exceeds the server’s header-size limit. Fix: keep filter state as plain values in memory and rebuild the query string from scratch each time instead of re-encoding the live URL.

A Web Application Firewall inspects incoming requests for malicious patterns. Attackers sometimes double-encode or use mixed-case hex to disguise a payload from a firewall that only decodes once. The takeaway for developers is defensive: encode consistently, and validate input after fully decoding it, not before. This is background on how encoding is abused, not a technique to use.

SEO and URL structure

Google decodes and crawls percent-encoded URLs without any ranking penalty, so functionally they’re fine. The real cost is human: a URL full of raw hex is harder to read and less likely to be clicked or shared in search results. Prefer readable slugs where you can, and reserve encoding for characters that genuinely need it.

Use clean UTF-8 percent-encoding, which is what Google recommends. A path like /gemüse should encode as /gem%C3%BCse. Google can decode UTF-8 paths and display the native characters in results, keeping international URLs both portable and readable.

Yes. The hex digits are case-insensitive per RFC 3986, but crawlers and analytics often treat the raw strings as distinct keys — so /caf%C3%A9 and /caf%c3%a9 can be indexed as two pages, splitting link equity. Emit one consistent case (uppercase is the RFC recommendation) and normalize at your CDN or proxy. See the troubleshooting guide for the full fix.

If navigation code generates endless malformed or nested query strings — for example infinite filter combinations — crawlers can get stuck scanning countless near-duplicate URLs. That wastes crawl budget and slows indexing of your real content. Keep parameters clean and canonical, and block or canonicalize filter permutations.

The browser treats # as the start of a fragment and never sends it — or anything after it — to the server. An unencoded # inside a campaign value silently drops your tracking parameters before they reach analytics. Encode it as %23 when it’s data, and build query strings with URLSearchParams instead of manual concatenation.

Using these tools

It depends whether the tool runs on a server or locally. urlencodedecode.com encodes entirely in your browser with client-side JavaScript — your input never leaves the tab, and it keeps working offline. That makes it safe for values containing tokens or other sensitive strings. Always confirm a tool is client-side before pasting anything sensitive.

UTF-8 (default and recommended), ASCII, all ISO-8859 variants (Latin-1 through Latin-10), Windows code pages (1250–1258), KOI8-R, KOI8-U for Cyrillic, Shift_JIS / EUC-JP / ISO-2022-JP for Japanese, GB18030 / GBK / Big5 for Chinese, EUC-KR / ISO-2022-KR for Korean, and the UTF-16 family.

Only for the file-upload feature, which is capped at 10 MB — a practical browser ceiling, since very large files can make the tab unresponsive. Typing or pasting text has no fixed limit, though extremely large pastes are processed in memory locally and can slow the tab. For files bigger than 10 MB, a command-line tool is a better fit — every operating system has a built-in URL encoder/decoder.

Ordinary strings and even long lists encode instantly. Very large inputs — multi-megabyte files — can slow or freeze a browser tab, since everything runs in memory on your machine. For everyday encoding and batches you won’t hit a limit; for huge files, a command-line tool is the better fit.

Yes. After the first page load, everything runs in your browser. You can disconnect your network and the encoder/decoder still works. The only requests the page makes are for fonts, analytics, and ads — none of which affect functionality.

Yes — both the URL you type into your address bar (with our tool's URL parameter) and a copy/paste of the encoded output are shareable. The encoder produces standard percent-encoded output that works in any web context.

For very large files, command-line utilities stream data and aren’t bound by browser memory. A short Python script using urllib.parse, or shell tooling, will encode files that would overwhelm a browser tab. For interactive, one-off encoding, the browser tool is faster and needs no setup.

Sources & standards

The answers on this page rest on the primary web standards that define percent-encoding, plus the official language documentation for the encode functions named:

  • RFC 3986 — URI Generic Syntax. Section 2.1 defines percent-encoding, Section 2.2 the reserved characters, Section 2.3 the unreserved set, and the case-insensitivity / uppercase-hex rule behind the duplicate-indexing question. rfc-editor.org/rfc/rfc3986 §2.1
  • WHATWG URL Standard. Defines the application/x-www-form-urlencoded serializer — the +-for-space convention used by HTML forms and URLSearchParams. url.spec.whatwg.org
  • RFC 3629 — UTF-8. The byte encoding percent-encoding wraps for non-ASCII characters, so é becomes %C3%A9. rfc-editor.org/rfc/rfc3629
  • Language references for the encode functions cited: Python urllib.parse, Java java.net.URLEncoder, Go net/url, PHP rawurlencode/urlencode, and JavaScript encodeURIComponent (MDN). Each language’s own docs are the authority on its exact behaviour.

Honest scope: the SQL and browser-memory notes describe general engine and environment behaviour, not anything fixed by a standard. The security answers describe how encoding is abused defensively — they aren’t an endorsement of any technique.