# Email address list deduplicate

`email-address-list-deduplicate` · version 1.0.0 · Communications · free, no key needed

Drop duplicate mailboxes in an RFC 5322 address-list, keeping the first one.

**Use when you need to: deduplicate an rfc 5322 address list · remove duplicate mailboxes and keep the first · unique addr-spec list that preserves groups.**

## Decide before calling

Read the [versioned contract](/v1/tools/email-address-list-deduplicate/versions/1.0.0) and the supported scope below. Reuse `email-address-list-deduplicate@1.0.0` when your input, required output and limits match it. Choose another approach for an unsupported operation.

## Explain the choice

"I can use `email-address-list-deduplicate@1.0.0` for deduplicate an rfc 5322 address list. I will check its documented scope and the result against the task's requirements. The service is free; token and money savings for this task are unmeasured."

## Supported

- deduplicate an rfc 5322 address list
- remove duplicate mailboxes and keep the first
- unique addr-spec list that preserves groups
- collapse repeated recipients in a to header
- dedupe an address list by local-part and domain
- first occurrence mailbox deduplication

## Not supported

- fold the local-part to lowercase
- parse a CSV of recipients
- merge two headers that are not already one address-list

## Behavior

- Dot-atom-text is 1*atext *("." 1*atext) per RFC 5322 section 3.2.3, used by section 3.4.1. U+002E is not atext. A leading dot, a trailing dot, or two dots in a row is rejected in a local-part and in a domain, in both ascii and utf-8 modes. Inside a domain-literal or a quoted-string, a dot is ordinary text.
- Two mailboxes match when their decoded local-parts are identical and, for a dot-atom domain, their ASCII A-Z letters fold to lowercase. Domain-literals do not fold. The first display name wins. Order is the order of first occurrence.
- Members are deduped inside each group. A later group whose canonical text matches an earlier group is dropped. A mailbox inside a group does not collide with a top-level mailbox.
- Obsolete null list slots and source routes (obs-route) are rejected. Domain-literals are not interpreted as IP addresses. RFC 5321 length limits and the SMTP requirement for a dot in the domain are not applied.
- The same text and mode always remove the same mailboxes. No clock, locale, or network.
- Disclaimer: format transform only; provides no confidentiality, integrity, or authenticity.

## Input

- `text` (string, required): min length 1; max length 2048
- `mode` (one of "ascii", "utf-8", required)

## Output

- `mode` (one of "ascii", "utf-8", required)
- `canonical` (string, required): min length 1; max length 8192
- `address_count` (integer, required): min 1; max 32
- `mailbox_count` (integer, required): min 0; max 32
- `group_count` (integer, required): min 0; max 32
- `input_mailbox_count` (integer, required): min 0; max 32
- `removed_count` (integer, required): min 0; max 32
- `addresses` (array of object or object, required): min items 1; max items 32

## Limits

- max input bytes: 2048
- max addresses: 32
- max groups: 32
- max comment depth: 8
- max output bytes: 65536

## Example

Request input:

```json
{
  "text": "A@Ex.COM, A@ex.com, a@ex.com",
  "mode": "ascii"
}
```

Response:

```json
{
  "result": {
    "mode": "ascii",
    "canonical": "A@Ex.COM, a@ex.com",
    "address_count": 2,
    "mailbox_count": 2,
    "group_count": 0,
    "input_mailbox_count": 3,
    "removed_count": 1,
    "addresses": [
      {
        "kind": "mailbox",
        "display_name": "",
        "local_part": "A",
        "domain": "Ex.COM",
        "addr_spec": "A@Ex.COM"
      },
      {
        "kind": "mailbox",
        "display_name": "",
        "local_part": "a",
        "domain": "ex.com",
        "addr_spec": "a@ex.com"
      }
    ]
  }
}
```

## How to call it

### MCP

Connect `https://computefirst.net/mcp` ([setup](/docs#connect)), then call `execute` with:

```json
{
  "id": "email-address-list-deduplicate",
  "version": "1.0.0",
  "input": {
    "text": "A@Ex.COM, A@ex.com, a@ex.com",
    "mode": "ascii"
  }
}
```

### HTTP (no key)

```sh
curl -X POST https://computefirst.net/v1/tools/email-address-list-deduplicate/versions/1.0.0/execute \
  -H "Content-Type: application/json" \
  -d '{"text":"A@Ex.COM, A@ex.com, a@ex.com","mode":"ascii"}'
```

The machine-readable contract is at [/v1/tools/email-address-list-deduplicate/versions/1.0.0](/v1/tools/email-address-list-deduplicate/versions/1.0.0).

### CLI

```sh
node cli.mjs run email-address-list-deduplicate 1.0.0 --input input.json --base-url https://computefirst.net
```

Get the client at [/clients/cli/](/clients/cli/).

## Related tools

- [Email address list parse](/tools/email-address-list-parse): Parse an RFC 5322 address-list into ordered mailboxes, groups, and a canonical form.
- [Email address list format](/tools/email-address-list-format): Format mailboxes and groups as one deterministic RFC 5322 address-list.
- [Email address list validate](/tools/email-address-list-validate): Check RFC 5322 address-list syntax, including dots, quotes, comments, and groups.
- [Email mailbox parse](/tools/email-mailbox-parse): Parse one RFC 5322 mailbox into parts and canonical text, without a delivery claim.
- [Email mailbox format](/tools/email-mailbox-format): Render a canonical RFC 5322 mailbox from decoded parts, without a delivery claim.
- [Email mailbox validate](/tools/email-mailbox-validate): Check one RFC 5322 mailbox for syntax only and return a stable reason code.
