Normalise Company, Title and Domain Fields

By Andrew Apell, creator of Flookup Data Wrangler. Updated

About the Author

Andrew Apell is the creator of Flookup Data Wrangler and has built data cleaning tools for Google Sheets since 2018.
Every Flookup result described here can be checked in the documentation.
Read Our Story for the background or contact the team with any questions about this post, including corrections, unclear steps or use cases we have not covered yet.

Key Takeaways

  • Normalise company, title and domain fields with a free method you can try in Google Sheets before you install anything, so every rule can be checked on your own data first.
  • The Apps Script examples read and write the sheet once.
  • Formula alternatives cover the common case while the script handles the awkward edges that arrive with a real export.
  • Every example keeps its source columns.

Introduction

A company list collected from forms and exports rarely agrees with itself. Acme Inc, ACME Incorporated and Acme Ltd can all describe one supplier, while a job title column mixes Sr Mktg Mgr with Senior Marketing Manager.

This guide builds three small normalisers in Google Sheets. They map suffixes to one form, expand title abbreviations and pull a clean company domain from an email or a link. Each rule lives in a dictionary you can edit.


Why Use Dictionaries

A dictionary is a list of inputs and the output you want for each one. It is easier to review than a long regular expression, and it fails visibly when a value is missing from the list.

FieldMapsFallback
Company suffixInc, Incorporated, Ltd, LLC, Corp to one chosen suffixOriginal text with proper case
Job titleSr, Mgr, Dir, Eng, VP to full wordsOriginal text with proper case
DomainCommon domain typos to correct domainsThe lower case domain as found

Keep the dictionaries short. Add an entry when a real export shows you the variant, not because you can imagine one.


The Ready-Made Apps Script

Open Extensions then Apps Script, paste the code below and run normaliseContactFields(). It reads columns A to C as email, company and job title, then writes three clean columns to the right.

/** Maps one input to one output, keeping the rule list easy to audit. */
const COMPANY_SUFFIXES = {
  inc: "Inc",
  incorporated: "Inc",
  ltd: "Ltd",
  limited: "Ltd",
  llc: "LLC",
  corp: "Corp",
  corporation: "Corp",
};
const JOB_TITLES = {
  sr: "Senior",
  jr: "Junior",
  mgr: "Manager",
  mktg: "Marketing",
  dir: "Director",
  eng: "Engineer",
  vp: "Vice President",
};
const DOMAIN_TYPOS = {
  "gmial.com": "gmail.com",
  "hotmial.com": "hotmail.com",
  "yahooo.com": "yahoo.com",
};

function titleCase_(text) {
  return String(text || "")
    .toLowerCase()
    .replace(/(^|\s)(\S)/g, (match, lead, letter) => lead + letter.toUpperCase());
}

function normaliseCompany_(name) {
  const words = String(name || "").trim().split(/\s+/);
  const mapped = words.map((word) => {
    const key = word.toLowerCase().replace(/[^a-z]/g, "");
    return COMPANY_SUFFIXES[key] || titleCase_(word);
  });
  return mapped.join(" ");
}

function normaliseTitle_(title) {
  const words = String(title || "").trim().split(/\s+/);
  return words
    .map((word) => JOB_TITLES[word.toLowerCase()] || titleCase_(word))
    .join(" ");
}

function normaliseDomain_(value) {
  let text = String(value || "").trim().toLowerCase();
  text = text.replace(/^https?:\/\//, "").replace(/^www\./, "");
  const at = text.indexOf("@");
  if (at !== -1) {
    text = text.slice(at + 1);
  }
  text = text.split("/")[0].split("?")[0];
  return DOMAIN_TYPOS[text] || text;
}

/** Reads email, company and title in columns A to C and writes clean columns D to F. */
function normaliseContactFields() {
  const sheet = SpreadsheetApp.getActiveSheet();
  const values = sheet.getDataRange().getValues();
  const output = [["Domain", "Company", "Job title"]];
  for (let r = 1; r < values.length; r += 1) {
    output.push([
      normaliseDomain_(values[r][0]),
      normaliseCompany_(values[r][1]),
      normaliseTitle_(values[r][2]),
    ]);
  }
  sheet.getRange(1, 4, output.length, 3).setValues(output);
}

The helper titleCase capitalises each word after a lower case conversion. That keeps the result readable when a value is not in either dictionary.

The suffix loop uses word boundaries so a name such as Incubator is not changed. Word boundaries matter more than they look: a plain text replacement would corrupt perfectly good company names.


A Worked Example

Source emailSource companySource titleResult
marie@zephyrion.comZephyrion IncSr Mktg Mgrzephyrion.com, Zephyrion Inc, Senior Marketing Manager
isaac@orbitra.coORBITRA LIMITEDEngorbitra.co, Orbitra Ltd, Engineer
https://www.helixa.io/teamHelixaData Scientisthelixa.io, Helixa, Data Scientist

The third row shows the domain function accepting a link as well as an email. That is useful when one source column came from a website form and another from a contact export.


Formula Alternatives

Extract a domain from an email:

=IFERROR(REGEXEXTRACT(LOWER(A2),"@([a-z0-9.-]+)"),"")

Standardise a company suffix using a lookup tab in columns G and H:

=IFERROR(VLOOKUP(LOWER(B2),$G$2:$H$20,2,FALSE),PROPER(B2))

Expand one title abbreviation:

=SUBSTITUTE(PROPER(C2),"Mgr","Manager")

These formulas work well for one column at a time. The script is better when the same three fields arrive in a new export every week and you want one output table.


Where the Rules Stop

Suffix normalisation does not identify companies. Two suppliers with the same trading name and different legal entities still need a human decision. For that job, use fuzzy matching on the company name and review the candidate pairs.

Title dictionaries are specific to your organisation. A title such as Engineer III may mean something different in two departments, so expand it only where you own the meaning.

Domain extraction is not email verification. A correctly spelled domain can still host an unused mailbox. Pair this step with the email checks before you treat an address as valid.


Make the Variants Agree

Normalisation is the boring work that makes matching possible. Put the variants into a dictionary, apply them in one pass and keep the original columns for audit.

Once the fields agree, matching can answer the harder question of which rows describe the same record. Flookup Data Wrangler does that inside the sheet with scored matches and a review step.


Frequently Asked Questions

What does company normalisation change?

It maps common suffixes such as Inc, Incorporated and Ltd to one chosen form. It does not merge two different companies that share a similar name.

How does the title map work?

A dictionary maps lower case abbreviations to full titles. Anything not in the dictionary is returned with proper case so nothing is silently dropped.

Can I extract a domain from a URL as well as an email?

Yes. The function strips the protocol, a leading www and any path, so a link and an email both produce a bare domain.

Why keep a dictionary instead of a regular expression?

A dictionary is easy to audit and easy to extend. A regular expression that covers every suffix becomes hard to read and harder to correct.

Can I do this with formulas alone?

Yes for a small dictionary. VLOOKUP against a lookup tab and REGEXEXTRACT for the domain cover the common cases; the script handles several fields in one pass.


You Might Also Like