Skip to content

normalizeEmail

Normalizes an email address by trimming whitespace, lowercasing, and optionally stripping plus-addressing (+alias). Useful for deduplicating emails since most providers route user+tag@example.com to the same mailbox as user@example.com.

import { normalizeEmail } from "1o1-utils";
import { normalizeEmail } from "1o1-utils/normalize-email";
function normalizeEmail({ email, stripPlus }: NormalizeEmailParams): string
NameTypeRequiredDescription
emailstringYesThe email address to normalize
stripPlusbooleanNoWhen true, drops everything from the first + in the local part up to (but excluding) the @. Default false

string

normalizeEmail({ email: " User@Email.COM " });
// => "user@email.com"
normalizeEmail({ email: "user+promotions@gmail.com", stripPlus: true });
// => "user@gmail.com"
normalizeEmail({ email: "user+1@email.com" });
// => "user+1@email.com" — default keeps plus-addressing
normalizeEmail({ email: "user+a+b@gmail.com", stripPlus: true });
// => "user@gmail.com" — strips from first plus
normalizeEmail({ email: "user@a+b.com", stripPlus: true });
// => "user@a+b.com" — plus in domain is preserved
  • Throws if email is not a string.
  • Throws if email is empty after trimming.
  • Lowercases both the local part and the domain.
  • stripPlus only touches the local part — a + that appears in the domain is preserved.
  • No format validation is performed. Pair with isValidEmail for that.

normalize email, lowercase email, dedupe email, plus addressing, strip plus

I'm using 1o1-utils (npm: https://www.npmjs.com/package/1o1-utils, GitHub: https://github.com/pedrotroccoli/1o1-utils, LLM context: https://pedrotroccoli.github.io/1o1-utils/llms.txt). Show me how to use normalizeEmail with stripPlus to deduplicate user signups by email.