Gmail Dot Trick: 2 ^ (N-1) 이메일 별칭 뒤에 숨겨진 수학 — 그리고 생성기 제작 방법

작성자

카테고리:

← 피드로
DEV Community · yahya wijaya · 2026-06-29 개발(SW)
Cover image for Gmail Dot Trick: The Math Behind 2^(n-1) Email Aliases — and How I Built a Generator

yahya wijaya

You probably know about Gmail’s dot trick — but do you know how many aliases your Gmail address actually has?

Spoiler: if your username is 10 characters, you have 512 aliases.

The Trick

Gmail completely ignores dots (.) in the local part of an email address. This means:

[email protected]
[email protected]
[email protected]
[email protected]

Enter fullscreen mode Exit fullscreen mode

All four land in the exact same inbox. Every single variant is a valid alias — Google officially documents this behavior.

This is useful for:

  • Signing up for trials repeatedly using “different” email addresses
  • Creating Gmail filters based on specific aliases
  • Testing email registration/validation systems in your app

The Math

For a username with n characters, there are n − 1 positions between characters. Each position can either have a dot or not — giving us:

Total aliases = 2^(n-1)

Enter fullscreen mode Exit fullscreen mode

Username length Aliases 5 chars 16 6 chars 32 8 chars 128 10 chars 512 12 chars 2,048

My username (yahyawijaya) has 11 characters → 1,024 aliases.

Implementing the Generator

Here’s the core logic in vanilla JavaScript:

function generateDotCombinations(username) {
  const chars = username.split('');
  const n = chars.length;
  const positions = n - 1; // number of gaps between chars
  const total = Math.pow(2, positions);
  const results = [];

  for (let i = 0; i < total; i++) {
    let combo = chars[0];
    for (let j = 0; j < positions; j++) {
      // Check if bit j is set in i
      if (i & (1 << j)) {
        combo += '.';
      }
      combo += chars[j + 1];
    }
    results.push(combo);
  }

  return results;
}

Enter fullscreen mode Exit fullscreen mode

How it works:

  • We iterate i from 0 to 2^(n-1) - 1
  • Each value of i is a bitmask — bit j being set means “place a dot at position j
  • For i = 0 (binary 000): no dots → johndoe
  • For i = 1 (binary 001): dot at position 0 → j.ohndoe
  • For i = 5 (binary 101): dots at positions 0 and 2 → j.oh.ndoe

This gives us all 2^(n-1) combinations in a clean loop.

Handling @gmail.com

When the user inputs a full email like [email protected], we need to:

  1. Strip existing dots from the local part
  2. Extract the domain
  3. Generate combinations on the clean username
  4. Re-attach the domain
function parseEmail(input) {
  const [local, domain] = input.split('@');
  const cleanLocal = local.replace(/\./g, ''); // remove existing dots
  return { username: cleanLocal, domain: domain || 'gmail.com' };
}

function generate(emailInput) {
  const { username, domain } = parseEmail(emailInput);
  const combos = generateDotCombinations(username);
  return combos.map(c => `${c}@${domain}`);
}

Enter fullscreen mode Exit fullscreen mode

The Full Tool

I wrapped this into a browser-based generator with:

  • Copy-all button (copies the full list to clipboard)
  • Stats showing total combinations + formula
  • Works with any domain, not just @gmail.com
  • Zero dependencies, zero server — runs entirely in the browser

👉 Try it: yahyawijaya.com/tools/email-dot

One Gotcha

Gmail’s dot-ignoring behavior only applies to Gmail addresses — not Google Workspace / G Suite custom domains. So [email protected] and [email protected] may or may not be the same, depending on how the mail server is configured.

Also: the plus alias trick ([email protected]) is a separate feature — dots and plus signs are two independent Gmail alias mechanisms.

Yahya Wijaya — Software Engineer
More tools at yahyawijaya.com/tools

원문에서 계속 ↗

코멘트

답글 남기기

이메일 주소는 공개되지 않습니다. 필수 필드는 *로 표시됩니다