
Email communication demands precision. The Email Typo Fixer is a lightweight TypeScript library that addresses complex email formatting challenges with trustworthy accuracy.
This library automatically corrects common typos and formatting errors in the email addresses you entered. It handles complex cases like domain typos, special characters, repeated “@” symbols, and more.
Some typical fixes include:
- [email protected] -> [email protected]
- cssscript@@gmail.com -> [email protected]
- cssscript@@gmail.com# -> [email protected]
- CSS Script <cssscript@@gmial..com#> -> [email protected]
Use Cases:
- E-commerce Platforms: Customers often mistype their email during checkout. This library intercepts and corrects those mistakes. It results in successful order confirmations and reduces customer service inquiries.
- Newsletter Subscriptions: Improve subscriber list quality. The library ensures your newsletters reach the intended recipients by fixing typos at the point of subscription.
- Internal Systems: Many companies experience issues with internal emails due to typos in employee addresses. This library ensures internal communications are delivered correctly.
How to use it:
1. Install the library using your preferred package manager:
# Yarn $ yarn add email-typo-fixer # NPM $ npm install email-typo-fixer # PNPM $ pnpm install email-typo-fixer # BUN $ bun add email-typo-fixer
2. The library provides a core function emailTypoFixer to process and correct email addresses.
import { emailTypoFixer, DEFAULT_DOMAINS } from 'email-typo-fixer';
const result = emailTypoFixer('cssscript@@gmail.com#');
console.log(result);3. Available options.
const result = emailTypoFixer('cssscript@@gmail.com#',{
// add your own domains here
domains: [
"gmail.com",
"yahoo.com",
"hotmail.com",
"outlook.com",
"icloud.com",
"aol.com"
"cssscript.com"
],
// defines how strict the library should be when correcting domain typos
// a lower value results in stricter corrections
domainMatchDistance: 2
});4. The emailTypoFixer function returns an object with the following properties:
interface EmailTypoFixerResult {
// The original email address you provided
original: string;
// The corrected email address
suggested: string | undefined;
// A boolean value indicating whether any corrections were made
hasCorrection: boolean;
}






