---
title: "Deduplicate company names in C#"
url: https://recursiveai.org/onecontact/cookbook/deduplicate-company-names/
description: "Group company name variants like Ltd and Limited in C# with a versioned OneContact key. See which names stay separate before merging records."
version: "1.0.0"
---

# Deduplicate company names 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/deduplicate-company-names/deduplicate-company-names.zip)

Group “Ltd” and “Limited” together.

```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;
string[] names = ["Lumen Quay Ltd",
    "LUMEN QUAY LIMITED"];
var unique = names.DistinctBy(name =>
    CompanyName.Parse(name)
        .GetKey(KeyVersion.V1));
Console.WriteLine(string.Join(", ", unique));
```

Unzip [the example](https://recursiveai.org/onecontact/cookbook/deduplicate-company-names/deduplicate-company-names.zip), then `dotnet run`.

```text
Lumen Quay Ltd
```

## Full program

```csharp
using RecursiveAI.OneContact;

string[] names =
[
    "Lumen Quay Ltd",
    "LUMEN QUAY LIMITED",
    "Lumen Quay",
    "Lumen Quay Inc",
    "Lumen Qauy Limited", // Intentional typo: a separate group.
    "",
];

var parsed = new List<(string Original, string Key)>();
foreach (string name in names)
{
    if (CompanyName.TryParse(name, out var company))
        parsed.Add((name, company.GetKey(KeyVersion.V1)));
    else
        Console.WriteLine("Skipped: empty or unparseable name");
}

foreach (var group in parsed.GroupBy(item => item.Key, StringComparer.Ordinal))
{
    Console.WriteLine(group.Key);
    foreach (var item in group)
        Console.WriteLine($"  {item.Original}");
}
```

`dotnet run` prints:

```text
Skipped: empty or unparseable name
lumen quay|~ltd
  Lumen Quay Ltd
  LUMEN QUAY LIMITED
lumen quay|
  Lumen Quay
lumen quay|~inc
  Lumen Quay Inc
lumen qauy|~ltd
  Lumen Qauy Limited
```

The program groups the original strings instead of discarding them, so you can see why each row landed in its group. If `TryParse` returns `false`, it skips that row rather than grouping it under a blank key.

## Variations

See the base name and parsed legal suffix before deciding how to label a group. `Region.Parse("GB")` narrows the legal-form candidates to UK matches when available:

```csharp
using RecursiveAI.OneContact;

var company = CompanyName.Parse(
    "Lumen Quay Limited", Region.Parse("GB"));
Console.WriteLine(company.Base);
Console.WriteLine(company.LegalForm?.Abbreviation);
```

```text
Lumen Quay
Ltd
```

## Related recipes

- [Parse a company name and legal suffix](https://recursiveai.org/onecontact/cookbook/parse-company-name/)
- [Deduplicate contacts by email or phone](https://recursiveai.org/onecontact/cookbook/deduplicate-contacts/)

## The short answer

To deduplicate a list of company names in C#, parse each name with `CompanyName` and compare `GetKey(KeyVersion.V1)` using ordinal string equality. Use `DistinctBy` for one label per key, or `GroupBy` to retain the originals for review. In the example, both spellings of Lumen Quay Limited produce `lumen quay|~ltd`. Neither the company with no suffix nor the one ending in `Inc` joins that group.

## How do you remove duplicates from a list of similar company names?

Group on the key, not on the input text. Case-insensitive comparison alone won’t match “Ltd” to “Limited”. The [company name rules](https://recursiveai.org/onecontact/docs/company-names/#company-key-v1) fold the base to lowercase words, treat `&` like “and”, and leave out the leading “The”, trading-as name and care-of text. The library doesn’t correct the base name. “Lumen Qauy Limited” stays in a different group even though a reader might guess it’s a typo.

If all you need is a dropdown of representative labels, you can use the compact version above. If you’re cleaning CRM rows, save the source row IDs alongside the key and choose the label explicitly, for example from the record with a verified registered name. That keeps a spelling found in an import from silently replacing a name you’ve already checked. Keep parse failures apart from the valid groups so you can fix or exclude them deliberately.

## What is a suffix in a company name?

A suffix like “Limited” is part of the company’s legal form, not just punctuation. OneContact looks for known forms and abbreviations, preferring the longest match at the end of the name. In V1, the part after `|` is an ISO 20275 Entity Legal Form code when the written form maps to one code; otherwise the parser can use a `~` token based on the common abbreviation, such as `~ltd`. If there is no legal form, the part after `|` is empty. Don’t strip that part of the key if the distinction matters to your list.

## Can two companies have the same normalized name?

Yes. A key contains name information, not a registration number or a lookup in a company register. Even the legal-form code describes the type of entity, not which entity it is. Treat a key match as a group of candidates. Before you merge legal-entity records, compare a reliable identifier, such as a registration number together with its jurisdiction. Where one name lacks a suffix or has a likely typo, send it to review instead of merging it just because the names look alike.
