SEOApr 14, 2026 · Updated Oct 13, 2026·8 min read

URL Encoding, Slugs & SEO-Friendly URLs

How percent-encoding works, what encodeURIComponent, encodeURI, URLSearchParams and new URL() each produce for the same input (we tested them), the decoding errors to plan for, Punycode, slugs, and how one page can answer at seven URLs.

🔗
Try the URL Encoder/Decoder
Encode and decode URLs instantly — free, no signup
→
DG
Derek Giordano
Designer & Developer
In this guide
01Anatomy of a URL02Percent-Encoding: What Has to Be Encoded03What Each JavaScript Function Produces04Decoding Traps05Query Strings and Parameters06Non-ASCII Text: Paths vs Hostnames07Slugs08One Page, Seven URLs09Do People Actually Read URLs?

Anatomy of a URL

Take https://www.example.com:443/blog/my-post/?ref=twitter#comments. RFC 3986, the standard Google and browsers follow, splits it into six parts, and they do not behave alike:

PartIn the exampleCase-sensitive?Sent to the server?
SchemehttpsNoYes
Hostwww.example.comNoYes (the Host header)
Port443 (the https default, usually left out)n/aYes
Path/blog/my-post/YesYes
Query?ref=twitterYesYes
Fragment#commentsYesNo, the browser keeps it

Google applies the same rules. Its URL guidelines say it treats /APPLE and /apple as two different URLs, and that it generally does not support fragments, so content that only changes after the # is not seen as separate pages.

Percent-Encoding: What Has to Be Encoded

RFC 3986 sorts ASCII characters into three groups. Unreserved characters (letters, digits and - . _ ~) never need encoding. Encoding one changes nothing by the standard: %7E and ~ are equivalent, and the RFC tells software not to produce the encoded form at all.

Reserved characters (: / ? # [ ] @ ! $ & ' ( ) * + , ; =) separate the parts of a URL. When one of them is data rather than structure, encode it: a literal & inside a query value has to be %26 or it starts a new parameter. Inside a path segment the standard is looser than most guides suggest: the sub-delimiters ! $ & ' ( ) * + , ; = plus : and @ may appear unencoded.

Anything outside ASCII is turned into UTF-8 bytes first, and each byte becomes %XX. é is the two bytes C3 A9, so café becomes caf%C3%A9; 🙂 is four bytes, %F0%9F%99%82.

The plus sign is where most bugs start. + means a space only in application/x-www-form-urlencoded data, the format HTML forms and URLSearchParams produce. RFC 3986 gives it no special meaning, so in a path such as /c++-tips/ it is simply a plus.

What Each JavaScript Function Produces

We ran the same strings through every built-in encoder in Node.js 22 (V8 12.4, the engine Chrome uses) on October 13, 2026, and through Python's urllib.parse for comparison. The script and full output are in our test folder.

InputencodeURIComponent()encodeURI()URLSearchParamsnew URL() path
hello world & morehello%20world%20%26%20morehello%20world%20&%20morehello+world+%26+morehello%20world%20&%20more
a+b=ca%2Bb%3Dca+b=ca%2Bb%3Dca+b=c
50% off50%25%20off50%25%20off50%25+off50%%20off
it's (fine)!*it's%20(fine)!*it's%20(fine)!*it%27s+%28fine%29%21*it's%20(fine)!*
~user~user~user%7Euser~user
C++ & C#C%2B%2B%20%26%20C%23C++%20&%20C#C%2B%2B+%26+C%23C++%20&%20C
path/with/slashpath%2Fwith%2Fslashpath/with/slashpath%2Fwith%2Fslashpath/with/slash

Decoding Traps

Query Strings and Parameters

Build query strings with URLSearchParams instead of joining strings by hand; it encodes each value and handles repeated keys:

const params = new URLSearchParams({ q: "hello world", page: "2", filter: "price<100" });
params.toString();
// "q=hello+world&page=2&filter=price%3C100"

const url = new URL("https://example.com/search");
url.searchParams.set("q", "café & crème");
url.searchParams.append("tag", "css");
url.searchParams.append("tag", "tools");
url.href;
// "https://example.com/search?q=caf%C3%A9+%26+cr%C3%A8me&tag=css&tag=tools"

Google's URL guidelines ask for the same plain convention: = between key and value, & between parameters, and a comma when one key has several values, not colons, brackets or doubled commas. They also ask you to drop parameters that do not change the content, such as referral tags and session IDs, because every variation is one more URL to crawl.

The URL standard sets no maximum length. HTTP's RFC 9110 recommends that every client and server support URIs of at least 8,000 octets, and a server that will not parse a longer one answers 414 (URI Too Long). Large payloads belong in a POST body.

Non-ASCII Text: Paths vs Hostnames

In the path and query, non-ASCII text is UTF-8 percent-encoded as shown above. Google recommends words in your audience's language, including scripts such as Arabic or Japanese, and asks you to put the encoded form in your links (its example is /gem%C3%BCse rather than /gemüse). Browsers decode it again for the address bar, so readers still see the word.

Hostnames work differently. DNS names only carry letters, digits and hyphens, so an internationalized domain is converted with Punycode (RFC 3492) and given an xn-- prefix: new URL("https://café.example/") comes back as https://xn--caf-dma.example/.

That conversion is also a security boundary. Letters from different scripts can look identical (Latin a and Cyrillic а), which lets attackers register lookalike domains. Suzuki and colleagues (ACM IMC 2019) counted 955,512 internationalized domains among 141.2 million .com names (0.67%) and found 3,280 lookalikes of the 10,000 most popular .com domains, 1,647 of them answering on the web. Chrome and Firefox now show the xn-- form when a hostname mixes scripts, so an internationalized domain that sticks to one script is the one readers will actually see as written.

Slugs

The slug is the last path segment, the part that names the page: css-gradient-guide in /blog/css-gradient-guide/. Everything above decides what it may contain, and Google's guidelines add two preferences: separate words with hyphens, not underscores (Google reads format_date as one concept, the way programmers write it), and keep one case, because case variants are different URLs to Google.

This is what our Slug Generator returns for awkward titles, using the tool's own function (October 13, 2026):

TitleSlug
The Complete Guide to CSS Gradients (2026)the-complete-guide-to-css-gradients-2026
C++ & C# for Beginnersc-plus-plus-and-c-sharp-for-beginners
Straße in Kölnstrasse-in-koln
Как сделать сайтkak-sdelat-sayt
It’s 50% Off!its-50-off
日本語のガイド日本語のガイド

The Japanese title stays as written and travels as %E6%97%A5%E6%9C%AC.... The generator transliterates and keeps every word; cutting filler such as "the complete guide to" is an editorial decision, and the URL Slug Optimizer can drop stop words for you. Settle the slug before publishing: a changed slug needs a permanent (301 or 308) redirect from the old URL, which Google counts as a strong signal that the new one is canonical.

One Page, Seven URLs

The server decides which spellings of a URL reach the same page, and many answer more than you would expect. We requested one of our own pages, hosted on Netlify, in nine forms on October 13, 2026:

RequestResponse
/tools/json-formatter/200, the page
/tools/json-formatter (no trailing slash)200, same page
/Tools/JSON-Formatter/200, same page
/tools/json%2Dformatter/200, same page
/tools%2Fjson-formatter/200, same page
/tools/json-formatter/?utm_source=test200, same page
/tools/json-formatter/index.html200, same page
www. host301 to the canonical URL
http://301 to the canonical URL

Seven URLs return the same page with a 200. Google treats /foo and /foo/ as separate URLs (its 2010 post on trailing slashes) and case variants as separate URLs (its URL guidelines), so each of those seven is a duplicate it has to fold into one. All of them carry the same rel="canonical" tag pointing at the slash version. Google's canonicalization guide ranks redirects and canonical tags as strong signals and sitemap inclusion as a weak one, and lists redirects first; a 301 from each variant would make the choice explicit.

Whatever your host does, link to one form everywhere, list only that form in your sitemap, and give every page a canonical tag. On Netlify a single moved page is one line in the _redirects file:

# Netlify _redirects
/old-page-name/   /new-page-name/   301

Do People Actually Read URLs?

Briefly. In Balatsoukas and Ruthven's eye-tracking study of Google results (Proceedings of ASIS&T, 2010), searchers gave the URL 1.7 fixations and 0.8 seconds on average, against 7 fixations and 2.8 seconds for the title and 5 fixations and 1.9 seconds for the snippet.

When people do read a URL, they read it loosely. Albakry, Vaniea and Wolters (CHI 2020) showed 1,929 participants 23 URLs and found a strong bias toward assuming a link leads to whichever organization is named in it, wherever the name sits; the most technical group did only slightly better. Reynolds and colleagues (CHI 2020) found that people identified the real host of genuine URLs 93% of the time but only 40% of the time for obfuscated lookalikes.

So a slug that matches the page title and a plain domain are what a reader can take in during that glance. Whether URLs affect rankings is a separate question, covered in our guide to SEO-friendly URLs.

DG
Derek Giordano
Written by the creator of Ultimate Design Tools. BA in Business Marketing.