Skip to the content.

1️⃣ What is Encoding?

Encoding is the process of transforming data from one format into another so that it can be stored, transmitted, or used more efficiently.

Example:


2️⃣ Why Encoding is Used

  1. Data Transmission:

    • Send binary data over text-based protocols (like email, JSON, URLs)
    • Example: Base64 encoding lets you send images via JSON safely
  2. Storage Efficiency:

    • Encode numeric or binary data in smaller formats
    • Example: Base36 encoding compresses numbers into shorter strings
  3. Interoperability:

    • Different systems understand different formats, encoding ensures compatibility

3️⃣ Common Types of Encoding

Encoding Type Purpose / Usage Example
ASCII / UTF-8 / UTF-16 Represent text as bytes "A" → 65 in ASCII
Base64 Encode binary as text (emails, JSON, XML) Image bytes → "iVBORw0KGgoAAA..."
Base32 Encode binary as text (shorter alphabet, case-insensitive) "JBSWY3DP"
Base16 / Hex Encode bytes in hexadecimal 255 → "FF"
Base36 Encode numeric IDs in alphanumeric characters (0-9, a-z) 123456 → "2n9c"
URL Encoding (Percent Encoding) Encode special characters for URLs " " → %20, "&" → %26
Binary / Bit-level encoding Store numbers in bits efficiently 5 → 101

4️⃣ Base36 Encoding

Example:

Decimal  -> Base36
123456   -> 2n9c
987654321 -> lfls1

5️⃣ Encoding vs Encryption vs Compression

Concept Purpose Reversible Security
Encoding Transform format ✅ ❌
Encryption Hide data / confidentiality ✅ ✅
Compression Reduce size ✅ ❌

6️⃣ Quick Analogy