ToolHub
View All Posts

URL Kodlama Açıklaması: Web Standardı Kılavuzu

URL'ler (Tekdüzen Kaynak Konumlandırıcıları), web'i nasıl gezindiğimizin temelidir, ancak URL'lerin yalnızca belirli karakterleri içerebileceğini biliyor muydunuz? Boşluklar, Latin olmayan karakterler veya özel semboller içeren bir web adresini her ziyaret ettiğinizde, URL kodlama tarayıcınızın bu karakterleri web sunucularının anlayabileceği bir formata dönüştürmesini sağlar. Bu kılavuz, URL kodlamanın ne olduğunu, nasıl çalıştığını ve neden gerekli olduğunu açıklar.

URL Kodlama Nedir?

URL kodlama (yüzde kodlama olarak da bilinir), özel karakterleri web üzerinden güvenli iletim için standart bir formata dönüştürme işlemidir. URL'ler yalnızca sınırlı bir ASCII karakter kümesi içerebildiğinden, bu aralığın dışındaki herhangi bir karakter, % işareti ve ardından iki onaltılık basamak kullanılarak kodlanmalıdır.

URL kodlama, URL'lerin tüm sistemler ve ağlar arasında doğru şekilde iletilmesini sağladığı için web'in temel bir parçasıdır. Kodlama olmadan, boşluklar, Latin olmayan karakterler veya URL'lerde özel anlamı olan semboller (&, =, ?, #) içeren URL'ler hatalı yorumlanır veya tamamen başarısız olur.

Yüzde Kodlama

URL'ler yalnızca ayrılmamış karakterler olarak bilinen karakterleri güvenle içerebilir: büyük ve küçük harfler (A-Z, a-z), rakamlar (0-9), tire (-), alt çizgi (_), nokta (.) ve tilde (~). Diğer tüm karakterler, URL'de özel bir anlamı varsa veya ASCII olmayan bir karaktere aitse kodlanmalıdır.

URL kodlama, yüzde kodlama adı verilen basit bir kuralı izler: her kodlanmış karakter, % işareti ve ardından karakterin ASCII (veya UTF-8) değerini temsil eden iki onaltılık basamakla temsil edilir. Örneğin, boşluk karakteri %20 olarak kodlanır çünkü boşluğun onaltılık ASCII değeri 20'dir.

Hangi Karakterlerin Kodlanması Gerekir

URL kodlama, URL'lerin tüm sistemler ve ağlar arasında doğru şekilde iletilmesini sağladığı için web'in temel bir parçasıdır. Kodlama olmadan, boşluklar, Latin olmayan karakterler veya URL'lerde özel anlamı olan semboller (&, =, ?, #) içeren URL'ler hatalı yorumlanır veya tamamen başarısız olur.

  1. JavaScript: encodeURIComponent() ve decodeURIComponent()
  2. Python: urllib.parse.quote() ve urllib.parse.unquote()
  3. Java: URLEncoder.encode() ve URLDecoder.decode()

URL kodlama nedir?

URL kodlama ve URL çözme ters işlemlerdir. Kodlama, özel karakterleri %XX formatına dönüştürürken, çözme %XX dizilerini tekrar orijinal karakterlerine dönüştürür. Bu işlemler simetriktir: kodlanmış bir URL'nin kodunu çözmek her zaman orijinal dizeyi döndürür.

URL kodlama ve Base64 kodlama, kavram olarak benzer ancak pratikte farklı olan iki farklı şeydir. Her ikisi de verileri web üzerinden iletim için uygun bir formata dönüştürür, ancak bunu farklı şekillerde ve farklı amaçlar için yaparlar.

URL Kodlama Nasıl Çalışır

URL'leri kodlamanız veya çözmeniz mi gerekiyor? İşlemi saniyeler içinde gerçekleştiren ücretsiz URL kodlama ve çözme aracımızı kullanın.

KarakterKodlanmışKarakterKodlanmış
Boşluk%20!%21
"%22#%23
$%24%%25
&%26'%27
(%28)%29
*%2A+%2B
,%2C/%2F
:%3A;%3B
<%3C=%3D
>%3E?%3F
@%40[%5B
\%5C]%5D
^%5E`%60
{%7B|%7C
}%7D~%7E
AmaçURL'lerdeki özel karakterleri kodlamaİkili verileri ASCII metnine dönüştürmeKodlama Yöntemi
%XX (onaltılık)64 karakterlik alfabe (A-Z, a-z, 0-9, +, /)KapsamYalnızca güvenli olmayan karakterleri kodlar
Tüm girdiyi kodlarÇıktı BoyutuOrijinaline yakın~%33 daha büyük

Yaygın URL Kodlama Örnekleri

URL kodlama (yüzde kodlama), özel karakterleri web üzerinden güvenli iletim için %XX formatına dönüştürme işlemidir. URL'ler yalnızca sınırlı bir ASCII karakter kümesi içerebildiğinden, boşluklar, Latin olmayan karakterler ve URL'de özel anlamı olan semboller kodlanmalıdır.

URL'de boşluk nasıl kodlanır?

Boşluklar URL'lerde %20 olarak kodlanır. Tarihsel olarak, boşluklar + işaretiyle de temsil edilirdi (application/x-www-form-urlencoded içerik türünde), ancak %20 artık URL yollarındaki boşluklar için standarttır. + işareti hala sorgu dizelerinde yaygın olarak kullanılır.

URL kodlama neden gereklidir?

URL kodlama gereklidir çünkü URL'ler yalnızca sınırlı bir ASCII karakter kümesi içerebilir. Kodlama olmadan, boşluklar, Latin olmayan karakterler ve özel semboller (&, =, ?, #) URL'lerin hatalı yorumlanmasına, bağlantıların kopmasına veya güvenlik açıklarına yol açar.

URL'deki hangi karakterlerin kodlanması gerekir?

ÖzellikURL KodlamaBase64 Kodlama
İkili Veriler için VerimlilikVerimsiz (%300 artış)Verimli (%33 artış)
Kullanım AlanıURL'ler, sorgu dizeleriE-posta ekleri, veri URI'leri, JWT belirteçleri
Example for < %3C&lt;
Example for & %26 &amp;
Example for " %22 &quot;
Purpose Safe URL transmission Prevent HTML injection
Specification RFC 3986 HTML Living Standard

<%3C>, > (%3E), # (%23), % (%25), { (%7B), } (%7D), | (%7C), \ (%5C), ^ (%5E), ~ (%7E), [ (%5B), ] (%5D), ` (%60), Latin olmayan karakterler (örneğin, Çince karakterler, Kiril) ve değerleri 127'den büyük olan tüm karakterler.

URL Kodlama ve URL Çözme

URL kodlama, URL'lerdeki özel karakterleri işler ve % işareti ve ardından iki onaltılık basamak kullanır. Base64, ikili verileri ASCII metnine dönüştürür ve 64 karakterlik bir alfabe (A-Z, a-z, 0-9, +, /) kullanır. URL kodlama karakter düzeyinde çalışır, Base64 ise bayt düzeyinde çalışır. Farklı amaçlara hizmet ederler ve URL kodlama çok daha basittir.

URL kodlama ve Base64 kodlama arasındaki fark nedir?

JavaScript provides three encoding functions, each with different behavior:

// encodeURI - encodes a complete URL
// Preserves: :, /, ?, #, &, =, +, @, ;, ,, !, ~, *, ', (, )
const url = encodeURI("https://example.com/search?q=hello world");
// Result: "https://example.com/search?q=hello%20world"

// encodeURIComponent - encodes a URL component
// Encodes ALL special characters including URL delimiters
const param = encodeURIComponent("price=100&discount=20");
// Result: "price%3D100%26discount%3D20"

// Never use escape() - it is deprecated
// It does not handle Unicode correctly

encodeURIencodeURIComponentencodeURIencodeURIComponent when you are encoding a single parameter value.

Python

from urllib.parse import quote, quote_plus, urlencode

# quote - standard URL encoding (spaces as %20)
encoded = quote("hello world&more")
# Result: "hello%20world%26more"

# quote_plus - spaces become + instead of %20
encoded_plus = quote_plus("hello world")
# Result: "hello+world"

# urlencode - encodes a dictionary as a query string
params = {"q": "hello world", "lang": "en"}
query = urlencode(params)
# Result: "q=hello+world&lang=en"

PHP

// urlencode - spaces become +
$encoded = urlencode("hello world&more");
// Result: "hello+world%26more"

// rawurlencode - RFC 3986 compliant (spaces as %20)
$raw = rawurlencode("hello world&more");
// Result: "hello%20world%26more"

Farklı Dillerde URL Kodlama

The space character has two common encodings, and understanding when to use each is important:

+application/x-www-form-urlencoded+ is a literal plus sign, not a space. Most server-side frameworks handle this correctly for query strings, but it can cause subtle bugs when encoding paths or working with custom URL schemes.

URL Kodlama ve Base64 Kodlama

URL encoding has significant security implications that every web developer must understand.

Double Encoding Attacks

%2527%27' on the second pass. If a security filter only checks the first decode, it would miss the malicious character. This can bypass input validation, cross-site scripting (XSS) filters, and SQL injection protections.

<script>%253Cscript%253E<script>, executing the attack.

URL Encoding Is Not Encryption

A common misconception is that URL encoding hides or protects data. It does not. URL encoding is trivially reversible; anyone can decode a percent-encoded string. Never use URL encoding as a substitute for encryption, authentication, or access control. Sensitive data like passwords, API keys, and personal information should never appear in URLs, encoded or not, because URLs are logged by browsers, servers, proxies, and can be visible in referrer headers.

Open Redirect Vulnerabilities

/redirect?url=https%3A%2F%2Fevil.com. If the application does not validate the target URL after decoding, attackers can use this to redirect users to phishing sites. Always validate decoded URL values against an allowlist of permitted domains.

Path Traversal

../../etc/passwd%2e%2e%2f%2e%2e%2f%65%74%63%2f%70%61%73%73%77%64. Web servers must decode and normalize paths before checking for traversal attacks.

Sıkça Sorulan Sorular

Encoding Query Parameters

When building URLs with dynamic query parameters, always encode the values:

const baseUrl = "https://api.example.com/search";
const query = "user input with special chars: & ? = #";
const url = `${baseUrl}?q=${encodeURIComponent(query)}`;
// Result: "https://api.example.com/search?q=user%20input%20with%20special%20chars%3A%20%26%20%3F%20%3D%20%23"

Encoding URL Paths

Path segments that contain special characters need encoding, but you must not encode the path separators:

const category = "electronics & gadgets";
const product = "USB-C cable (6ft)";
const url = `/products/${encodeURIComponent(category)}/${encodeURIComponent(product)}`;
// Result: "/products/electronics%20%26%20gadgets/USB-C%20cable%20(6ft)"

Decoding URL Components

const encoded = "hello%20world%3F%26%3D%23";
const decoded = decodeURIComponent(encoded);
// Result: "hello world?&=#"

Common Pitfalls

Hızlı İpucu: JavaScript'te, encodeURIComponent() ve encodeURI() arasındaki farkı unutmayın. encodeURIComponent(), sorgu parametresi değerleri için uygun olan /?=& gibi karakterleri kodlar. encodeURI(), tam URL'ler için uygun olan URL yapısını korur.

Need to encode or decode URLs quickly? Try our free online URL encoder and decoder tools.

URL Kodlayıcı / ÇözücüDecode URL

Frequently Asked Questions

What is URL encoding?

URL encoding, also called percent-encoding, is a mechanism that converts characters into a format that can be safely transmitted in a URL. It replaces unsafe or reserved characters with a percent sign followed by two hexadecimal digits representing the character's byte value. For example, a space becomes %20 and a question mark becomes %3F.

Why do some URLs contain %20?

%20 is the URL-encoded representation of a space character. Spaces are not allowed in URLs because they can be ambiguous and break URL parsing. The percent sign followed by 20 represents the hexadecimal value 0x20, which is the ASCII code for a space. Some systems also use + for spaces in query strings, but %20 is the standard encoding.

What is the difference between URL encoding and HTML encoding?

URL encoding converts characters to percent-encoded format (%XX) for safe transmission in URLs. HTML encoding converts characters to entity references (&, <, etc.) for safe display in HTML documents. They serve different purposes: URL encoding is for URLs, HTML encoding is for HTML content. A value like < needs both: %3C in a URL and &lt; in HTML.

When should I use encodeURIComponent vs encodeURI?

Use encodeURI when encoding a complete URL, as it preserves URL structure characters like :, /, ?, &, and =. Use encodeURIComponent when encoding a single URL component value (like a query parameter), as it encodes ALL special characters including those that have structural meaning in URLs. Always use encodeURIComponent for query parameter values.

Can URL encoding be used for security?

URL encoding alone is not a security measure. It is a transport mechanism, not encryption or authentication. In fact, double encoding attacks can bypass security filters by encoding malicious input multiple times. Always validate and sanitize input on the server side, use parameterized queries for databases, and apply proper output encoding for the target context (HTML, URL, JavaScript).