encodeURIComponent: for one query value or path segment. Encodes / ? & = # and spaces as %20.
What URL encoding does
A URL can only contain a small set of ASCII characters, and some of those have a job: ? starts the query string, & separates parameters, # starts the fragment. Percent-encoding lets you put any other character, or one of those characters as plain data, into a URL by writing its byte value as % plus two hex digits.
Characters outside ASCII are converted to UTF-8 first, and each byte is encoded separately. That is why one character can turn into several escapes:
space → %20
& → %26
é → %C3%A9 (2 UTF-8 bytes)
€ → %E2%82%AC (3 UTF-8 bytes)
q=fish & chips → q=fish%20%26%20chipsDecoding reverses the process. The tool reads each run of escapes as UTF-8, so %E2%82%AC comes back as a single € rather than three broken characters.
Which encoding style to use
There is no single “correct” encoding. The four options in the tool match the four rule sets you will actually meet:
| Style | Left unencoded | Use it for |
|---|---|---|
Component (encodeURIComponent) | A–Z a–z 0–9 - _ . ! ~ * ' ( ) | A single query value or path segment. The safe default. |
Full URL (encodeURI) | The above plus ; / ? : @ & = + $ , # | A whole URL that contains spaces or non-ASCII characters but is otherwise correct. |
| RFC 3986 | A–Z a–z 0–9 - . _ ~ only | OAuth 1.0 signatures, AWS Signature V4 and other APIs that sign the encoded string. |
| Form (+) | A–Z a–z 0–9 * - . _; space becomes + | POST bodies and query strings built like an HTML form. |
The most common mistake is running encodeURIComponent over a whole URL. It encodes the slashes and colon too, so https://example.com/a b becomes https%3A%2F%2Fexample.com%2Fa%20b, which no browser will open. Encode the individual values, then assemble the URL.
Common URL-encoded characters
| Character | Encoded | Character | Encoded |
|---|---|---|---|
| space | %20 (or + in forms) | / | %2F |
! | %21 | : | %3A |
" | %22 | ; | %3B |
# | %23 | = | %3D |
$ | %24 | ? | %3F |
% | %25 | @ | %40 |
& | %26 | [ | %5B |
' | %27 | ] | %5D |
+ | %2B | , | %2C |
Hex digits are case-insensitive, so %2f and %2F decode to the same character. RFC 3986 recommends uppercase, which is what this tool produces.
URL encoding in code
Every language has the same split between “component” and “form” encoding; the function names are what trip people up.
// JavaScript
encodeURIComponent("fish & chips") // "fish%20%26%20chips"
decodeURIComponent("caf%C3%A9") // "café"
new URLSearchParams({ q: "fish & chips" }).toString() // "q=fish+%26+chips"
# Python
from urllib.parse import quote, quote_plus, unquote
quote("a b/c") # "a%20b/c" ("/" is safe by default)
quote("a b/c", safe="") # "a%20b%2Fc"
quote_plus("a b&c") # "a+b%26c"
unquote("caf%C3%A9") # "café"
// PHP
rawurlencode("a b"); // "a%20b" (RFC 3986)
urlencode("a b"); // "a+b" (form)
// Java
URLEncoder.encode("a b", StandardCharsets.UTF_8); // "a+b" (form rules)
// C#
Uri.EscapeDataString("a b"); // "a%20b"
// Go
url.PathEscape("a b") // "a%20b"
url.QueryEscape("a b") // "a+b"Note that Java's URLEncoder and PHP's urlencode produce form encoding. If you use them for a path, spaces arrive as literal plus signs.
Fixing common encoding problems
- Double encoding (
%2520,%253A). A value was encoded, then encoded again. The tool flags this after decoding and lets you decode another pass. Fix the source by encoding each value exactly once, at the point where it is put into the URL. - Plus signs turning into spaces. A server that parses form data reads
+as a space, so a phone number like+44arrives as44. Encode a literal plus as%2B. - “URI malformed” errors. A stray
%(for example “50% off” pasted into a URL) or a Latin-1 byte like%E9makesdecodeURIComponentthrow. The tool decodes what it can and lists each sequence it had to leave alone. - Broken redirect parameters. A URL passed inside another URL, as in
?redirect=/cart?id=42, must be encoded with component rules (%2Fcart%3Fid%3D42), or its?and&will be read as part of the outer URL.
URL encoding and SEO
Google's URL structure guidelines ask for UTF-8 percent-encoding when a URL contains non-ASCII characters, and browsers show those URLs decoded in the address bar. Encoded URLs are crawlable, but they are hard to read in search results, analytics reports and shared links. For pages you control, use short, lowercase ASCII slugs; the SEO Slug Generator builds them from a title. If you change existing URLs, redirect the old versions and confirm each one resolves in a single hop with the Redirect Checker.
Campaign links are where encoding most often breaks tracking. A UTM value with a space or & in it, such as utm_campaign=spring sale & clearance, must be encoded or everything after the & is read as a new parameter.
Frequently asked questions
What is URL encoding?
URL encoding, also called percent-encoding, replaces characters that are not allowed or have a special meaning in a URL with a percent sign followed by two hexadecimal digits. A space becomes %20, an ampersand becomes %26, and non-ASCII characters are first converted to UTF-8 bytes, so é becomes %C3%A9.
Should a space be encoded as %20 or +?
Use %20 anywhere in a URL. The plus sign means a space only in application/x-www-form-urlencoded data, which is what HTML forms send and what most servers parse in query strings. In a path, a + is a literal plus sign, so %20 is the safe choice when you are unsure.
What is the difference between encodeURI and encodeURIComponent?
encodeURI is for a complete URL: it leaves characters that structure a URL, such as : / ? # & =, untouched. encodeURIComponent is for one piece of a URL, such as a single query value: it encodes those characters too, so a value containing & or = cannot break the query string.
Why does my URL contain %2520?
It has been encoded twice. The first pass turned a space into %20; the second pass encoded the % sign itself as %25, giving %2520. Decode it twice to get the original text, then fix the code or plugin that encodes an already-encoded value.
Why does decoding fail with “URI malformed”?
JavaScript's decodeURIComponent throws that error when it meets a % that is not followed by two hex digits, or bytes that are not valid UTF-8, such as %E9 from a Latin-1 system. This decoder keeps those sequences unchanged, decodes everything else, and lists the exact positions it could not decode.
Is the text I paste sent to a server?
No. Encoding and decoding run in your browser with JavaScript. Nothing you type is uploaded, logged or stored, so it is safe to decode URLs that contain tokens or customer data.
Related Tools
- Base64 Decode & Encode — Decode Base64 to text, images or files and encode text or files to Base64 and data URIs.
- CSV to JSON Converter — Convert CSV to JSON with delimiter detection, correct handling of quoted fields and leading zeros, and array, keyed-object or JSON Lines output.
- JSON to CSV Converter — Convert JSON or JSON Lines to CSV with nested-object flattening, array handling, an Excel-friendly UTF-8 BOM and protection against formula injection.
- Cron Expression Generator — Build and read cron expressions in plain English, see the next 10 run times, and convert between crontab, Spring, Quartz and AWS EventBridge formats.
- CSS Minifier & Beautifier — Minify CSS with only rendering-safe changes, keeping licence comments, strings and calc() intact, or beautify minified CSS into readable, indented code.
- UTM Builder — Build UTM-tagged campaign links and see which GA4 channel each one will be reported under.