---
title: "Normalize an email address domain in C#"
url: https://recursiveai.org/onecontact/cookbook/canonicalize-email-domain/
description: "Lowercase an email domain and convert internationalized domains to ASCII in C# with OneContact, without lowercasing or stripping tags from the local part."
version: "1.0.0"
---

# Normalize an email address domain in C#

**OneContact** is a free, open-source contact data library for .NET from Recursive AI. MIT or Apache-2.0, no native dependencies, no network access.

[NuGet](https://www.nuget.org/packages/RecursiveAI.OneContact) · [GitHub](https://github.com/recursive-ai-oss/onecontact-csharp) · [Docs](https://recursiveai.org/onecontact/docs/) · [Download example (.zip)](https://recursiveai.org/onecontact/cookbook/canonicalize-email-domain/canonicalize-email-domain.zip)

Normalize the part after `@` without lowercasing the mailbox name or removing its `+tag`.

```shell
dotnet add package RecursiveAI.OneContact
```

Requires [.NET 10](https://dotnet.microsoft.com/download/dotnet/10.0) (net10.0); .NET 9 and earlier aren’t supported.

```csharp
using RecursiveAI.OneContact;

var email = EmailAddress.Parse(
    "Casey+news@EXAMPLE.COM");
Console.WriteLine(email.Canonical);
```

Unzip [the example](https://recursiveai.org/onecontact/cookbook/canonicalize-email-domain/canonicalize-email-domain.zip), then `dotnet run`.

```text
Casey+news@example.com
```

## Full program

```csharp
using RecursiveAI.OneContact;

string[] inputs =
[
    "Casey+news@EXAMPLE.COM",
    "Casey <Casey+news@Bücher.example>",
    "\"A@B\"@EXAMPLE.COM",
    "Casey@example..com",
];

foreach (string input in inputs)
{
    if (EmailAddress.TryParse(input, out var email))
        Console.WriteLine(email.Canonical);
    else
        Console.WriteLine($"Invalid mailbox syntax: {input}");
}
```

`dotnet run` prints:

```text
Casey+news@example.com
Casey+news@xn--bcher-kva.example
"A@B"@example.com
Invalid mailbox syntax: Casey@example..com
```

`TryParse` returns `false` for malformed input such as `Casey@example..com`, whose domain has an empty label. This is a syntax check, not a check that the domain or mailbox can receive mail.

## Variations

Read just the domain when you need it as a separate field. `Domain` gives the ASCII form; `UnicodeDomain` gives the Unicode form for display:

```csharp
using RecursiveAI.OneContact;

var email = EmailAddress.Parse(
    "Casey@Bücher.example");
Console.WriteLine(email.Domain);
Console.WriteLine(email.UnicodeDomain);
```

```text
xn--bcher-kva.example
bücher.example
```

## Related recipes

- [Validate an email address](https://recursiveai.org/onecontact/cookbook/validate-email-address/)
- [Detect email addresses that require SMTPUTF8](https://recursiveai.org/onecontact/cookbook/detect-email-addresses-requiring-smtputf8/)

## The short answer

In C#, parse one mailbox with `EmailAddress.Parse` and use `Canonical` for the normalized address. OneContact lowercases the domain and converts internationalized domain labels to ASCII. It doesn’t lowercase the local part or apply provider-specific alias rules. If you only want the normalized domain, read `Domain` instead.

## Do capital letters make a difference in an email address?

It depends on which side of `@` you mean. [RFC 5321, section 2.4](https://www.rfc-editor.org/rfc/rfc5321#section-2.4) says mailbox domains aren’t case-sensitive, but SMTP implementations must preserve the local part’s case. That’s why the first example changes `EXAMPLE.COM` to `example.com` but keeps `Casey`. Don’t lowercase the entire input as a shortcut.

The local part can also contain a quoted `@`, as in the third input of the full program. The parser keeps the quotes and the `@` inside them. It reads one mailbox and can take it from `Display Name <address>`, but the display name isn’t part of `Canonical`. As the [email docs](https://recursiveai.org/onecontact/docs/email/#canonical-form) explain, canonicalization also removes comments, folding and whitespace around dots; it isn’t a byte-for-byte copy of everything before the domain.

## How do you normalize an internationalized email domain?

For a domain such as `Bücher.example`, `Domain` returns `xn--bcher-kva.example`. This ASCII form uses IDNA (Internationalized Domain Names in Applications). The parser checks the domain labels as it processes them, so invalid ones don’t turn into a canonical address. The [IDNA docs](https://recursiveai.org/onecontact/docs/idna/) explain the rules. An ASCII domain does not make the whole address ASCII: a non-ASCII local part is a separate matter and needs SMTPUTF8 for delivery.

## Does plus addressing work for all emails?

Don’t assume it does. The receiving system determines what `+` means in a local part. `Canonical` keeps `Casey+news` intact; it doesn’t decide that it reaches the same mailbox as `Casey`. OneContact also exposes an [email comparison key](https://recursiveai.org/onecontact/docs/email/#key-keyversionv1) with different rules, including some provider-specific handling. Use the canonical address for domain normalization, not the comparison key. Keep address normalization separate from any decision to treat two addresses as interchangeable.
