# Normalize an email address for comparison

Trim whitespace and lowercase only the domain, preserving the local part.

Canonical: https://1loc.dev/email/normalize-an-email-address/
Version: 1.0.0
Runtime: JavaScript · Node.js 22 / modern browsers
Verification: Local fixtures; no external services
Updated: 2026-10-28

## Implementation

```javascript
function normalizeEmail(address) { const value = address.trim(); const at = value.lastIndexOf('@'); return `${value.slice(0, at)}@${value.slice(at + 1).toLowerCase()}`; }
```

## Input

```json
"  Ana.Silva@Example.COM "
```

## Expected output

```json
"Ana.Silva@example.com"
```

## Edge case

Input:
```json
"ANA@EXAMPLE.COM"
```
Output:
```json
"ANA@example.com"
```

## Limits

- The local part is kept as typed: its case rules belong to the receiving server.
- Provider-specific rules such as ignored dots or +tags are not applied. Do not merge accounts on this alone.

The lab validates types and size before calling this function. Add equivalent validation at your own trust boundary.

## Source and license

Author: Oveyon, written for this edition; not part of the original 1loc collection.
Copyright (c) 2026 Oveyon
License: MIT — https://1loc.dev/licenses/
Maintainer: Oveyon
