Menu

Base62 Encode & Decode

What is Base62?

Base62 is a binary-to-text encoding scheme that uses 62 characters to represent data: digits (0-9), lowercase letters (a-z), and uppercase letters (A-Z). It's commonly used when data needs to be represented compactly using only alphanumeric characters.

How It Works

Encoding: Input data (typically treated as a large integer derived from bytes) is repeatedly divided by 62. The remainders of these divisions correspond to characters in the Base62 alphabet (0-9, a-z, A-Z, in order). The characters are assembled (often in reverse order of calculation) to form the Base62 string.

Decoding: Each character in the Base62 string is converted back to its numerical value (0-61). These values are used to reconstruct the original large integer by multiplying the accumulated value by 62 and adding the value of the current character. The resulting integer can then be converted back to its original byte representation.

  • Uses characters 0-9, a-z, A-Z.
  • Case-sensitive (unlike Base32).
  • No padding characters are used.
  • Often used for numerical IDs or binary data where compactness and alphanumeric-only output are desired.
  • Not standardized by an RFC like Base64 or Base32, so character order (e.g., 0-9a-zA-Z vs 0-9A-Za-z) can vary between implementations. This tool uses `0-9a-zA-Z`.

Use Cases

Base62 encoding is popular for several applications:

  • URL Shorteners: Services like TinyURL and Bitly use Base62 (or similar high-base encodings) to create short, alphanumeric IDs from database primary keys.
  • Database IDs: Representing large numerical database IDs (like 64-bit integers) in a shorter, URL-friendly format.
  • Obfuscation: Simple way to make numerical IDs less obviously sequential.
  • API Keys/Tokens: Sometimes used for generating short, relatively easy-to-handle tokens.

Why Use Base62?

Its primary advantages are compactness and the use of only alphanumeric characters:

  • Compactness: More compact representation than Base32 or Hexadecimal for large numbers or binary data.
  • Alphanumeric Only: Output is safe for URLs, filenames, and systems where special characters (+, /, =) might cause issues.
  • Simplicity: The concept is relatively straightforward, based on standard base conversion.

Note: Like other Base encodings, Base62 provides no security and is easily reversible.

How to Use This Tool

  1. Select either "Encode" or "Decode" mode.
  2. Enter the text (UTF-8 for encoding) or Base62 string (0-9, a-z, A-Z for decoding) into the top input field.
  3. The result will appear automatically in the bottom output field.
  4. Use the swap button () to switch the input and output, automatically changing the mode.
  5. Click the copy icon () next to the output label to copy the result.
  6. Error messages will appear for invalid input characters or if the decoded data is not valid UTF-8.