Why URLs Need Encoding

URLs can only contain a limited set of ASCII characters. Characters like spaces, &, =, #, and non-ASCII characters (accents, CJK, emoji) must be percent-encoded — converted to %XX hex codes — to be valid in a URL.

How Percent-Encoding Works

Each byte of the character's UTF-8 representation is encoded as % followed by two hex digits. For example:

  • Space → %20 (or + in query strings)
  • &%26
  • @%40
  • cafe with accent → caf%C3%A9

Reserved vs Unreserved Characters

RFC 3986 defines unreserved characters that never need encoding: A-Z a-z 0-9 - _ . ~. Everything else is either reserved (has special meaning in URLs) or must be encoded. Reserved characters include : / ? # [ ] @ ! $ & ' ( ) * + , ; =.

Common Encoding Mistakes

  • Double encoding — encoding an already-encoded string turns %20 into %2520
  • Not encoding query values — if a value contains & or =, it breaks the parameter parsing
  • Using + outside query strings+ means space only in application/x-www-form-urlencoded

Encode and Decode Instantly

Use the URL Encoder on CodeKitLab to encode or decode any string for safe URL use. Need to inspect the full structure of a URL? The URL Parser breaks any URL into its protocol, hostname, port, path, query params, and fragment.

URL Encoding in Code

In JavaScript, use encodeURIComponent() for query parameter values and encodeURI() for full URLs. In Python, use urllib.parse.quote(). In PHP, use urlencode() for query strings or rawurlencode() for path segments.

When to Encode

  • User-provided input in query strings
  • File names with spaces or special characters
  • Redirect URLs passed as query parameters
  • Any non-ASCII text in URLs

URL encoding is one of those invisible necessities of the web. Get it wrong and your links break, your APIs fail, and your users see garbled text. Get it right and everything just works.

URL-kodning och avkodning

URLer kan bara innehalla begransade ASCII-tecken. Specialtecken maste procentkodas. Anvand URL Encoder for att koda och avkoda. Analysera URL-strukturen med URL Parser.

URL-Kodierung und Dekodierung

URLs konnen nur begrenzte ASCII-Zeichen enthalten. Sonderzeichen mussen prozentkodiert werden. Nutzen Sie den URL Encoder zum Kodieren und Dekodieren. Analysieren Sie die URL-Struktur mit dem URL Parser.

Encodage et decodage d'URL

Les URLs ne peuvent contenir qu'un ensemble limite de caracteres ASCII. Les caracteres speciaux doivent etre encodes en pourcentage. Utilisez l'URL Encoder pour encoder et decoder. Analysez la structure avec l'URL Parser.

Codificacion y decodificacion de URL

Las URLs solo pueden contener un conjunto limitado de caracteres ASCII. Los caracteres especiales deben codificarse en porcentaje. Usa el URL Encoder para codificar y decodificar. Analiza la estructura con el URL Parser.

ترميز وفك ترميز URL

لا يمكن أن تحتوي عناوين URL إلا على مجموعة محدودة من أحرف ASCII. يجب ترميز الأحرف الخاصة بالنسبة المئوية. استخدم URL Encoder للترميز وفك الترميز. حلل البنية باستخدام URL Parser.

URL انکوڈنگ اور ڈی کوڈنگ

URLs میں صرف محدود ASCII حروف ہو سکتے ہیں۔ خاص حروف کو فیصد انکوڈ کرنا ضروری ہے۔ URL Encoder سے انکوڈ اور ڈی کوڈ کریں۔ URL Parser سے ساخت کا تجزیہ کریں۔