الترميز
URL Encode/Decode
ترميز وفك ترميز URL — الأحرف التي يجب ترميزها في الروابط ومعاملات الاستعلام.
URL encoding (percent-encoding) replaces characters that aren't allowed in a URL — spaces, non-Latin letters, special characters — with %XX sequences, where XX is the hex code of the byte. This keeps links and query parameters from getting mangled in transit.
How to use it
- Encode: paste text or a URL and any character outside the safe ASCII set is replaced with a %XX sequence.
- Decode: paste an encoded string to see the original text.
- Encoding a full URL and encoding a single query parameter use slightly different safe-character sets — pick the mode that matches what you're encoding.
Common uses
- Building query parameters from text containing spaces, ampersands, or non-Latin characters.
- Debugging why a link with a parameter breaks — often the cause is an unencoded special character.
- Decoding URLs from third-party systems to read them in their original form.
Things to keep in mind
Encode parameter values, not the whole URL at once — otherwise you'll also encode the separators you need (:, /, ?, &).
JavaScript's encodeURIComponent and encodeURI encode different character sets — the former is meant specifically for parameter values.
مقالة عن هذه الأداة: URL Encode/Decode: الترميز بالنسبة المئوية في الروابط
الأسئلة الشائعة
ما الفرق بين ترميز URL وترميز Base64؟
ترميز URL (percent-encoding) يستبدل الأحرف الخاصة برمز النسبة المئوية متبوعًا بقيمتها السداسية عشرية مثل %20 للمسافة، بينما Base64 هو ترميز مختلف تمامًا لتحويل بيانات ثنائية إلى نص. كثيرون يخلطون بينهما وبين ما يسمى Base64 URL-safe.
ما الفرق بين وضعي Component وURI؟
وضع Component (مثل encodeURIComponent) يرمّز كل الأحرف الخاصة بما فيها & و= و؟ لأنه مخصص لتمرير قيمة داخل معامل استعلام واحد، بينما وضع URI (مثل encodeURI) يترك أحرف بنية الرابط الأساسية مثل : / ؟ # بدون ترميز لأنه مخصص لرابط كامل.
هل يتم إرسال الروابط أو النصوص التي أُدخلها إلى خادم؟
لا، الترميز وفك الترميز يتمّان بالكامل داخل المتصفح عبر JavaScript، دون أي اتصال بخادم أو تخزين للبيانات.
ما هو الترميز المزدوج وكيف يمكن التعرف عليه؟
هو خطأ يحدث عندما تُرمَّز سلسلة مُرمَّزة مسبقًا مرة أخرى — إذ يتحول الرمز % نفسه إلى %25، فيصبح %20 هو %2520. العلامة الدالة على هذه المشكلة هي ظهور تسلسلات مثل %25XX في النتيجة بعد فك الترميز.
لماذا تُرمَّز المسافة أحيانًا كـ + وأحيانًا كـ %20؟
ترميز المسافة كـ + هو صيغة application/x-www-form-urlencoded التي تستخدمها النماذج وسلاسل الاستعلام، بينما %20 هو الترميز القياسي percent-encoding وفق RFC 3986، وهو صحيح في أي جزء من عنوان URL.