Outbound & GTM

Clean a list of Dirty Company Names

Clean messy company names inside Google Sheets with a simple copy-paste Apps Script. Normalize case, strip junk, and prep lists for enrichment.

Free Company Name Cleaner For Google Sheets

Clean messy company names inside Google Sheets with a simple copy-paste Apps Script.

No paid tools.

No add-ons.

No complicated setup.

Just paste the script, save it, run it, and get a new column with cleaned company names.


What this does

This script takes messy company names like:

company name


ACME INC.


stripe.com


[email protected]


OpenAI LLC


THE NORTH FACE, INC.


salesforce.co.uk


Alphabet (Google) Ltd


And turns them into cleaner names like:

cleaned company name


Acme


Stripe


HubSpot


OpenAI


The North Face


Salesforce


Alphabet



Why this is useful

Messy company names make lead lists look bad.

They create problems in:

  • Cold email personalization
  • CRM cleanup
  • Lead list formatting
  • Company deduplication
  • Google Sheets workflows
  • Outbound campaign prep
  • Data enrichment
  • Reporting

If your cold email says:

Saw what you’re doing at ACME INC LLC

It instantly feels automated.

But if it says:

Saw what you’re doing at Acme

It feels cleaner and more natural.

Small detail, big difference.


What the script cleans

The script can help with:

  • Removing legal suffixes like LLC, Ltd, Inc, Corp, GmbH, Pvt Ltd, Pty Ltd, and more
  • Turning domains into company names
  • Turning email addresses into company names
  • Removing URLs
  • Removing messy symbols and separators
  • Fixing spacing
  • Applying smart title casing
  • Preserving common brand formatting like OpenAI, GitHub, LinkedIn, YouTube, PayPal, TikTok, SaaS, B2B, and more

Sheet setup

Your Google Sheet must have a column with this exact header:

company name

The script will create or update a new column called:

cleaned company name

Example:

company name cleaned company name
OpenAI LLC OpenAI
hubspot.com HubSpot
[email protected] Salesforce
ACME INC. Acme

How to install

Step 1

Open your Google Sheet.

Step 2

Go to:

Extensions > Apps Script

Step 3

Delete anything already inside the Apps Script editor.

Step 4

Paste the full script below.

Step 5

Click Save.

Step 6

From the function dropdown, select:

cleanCompanyNames

Step 7

Click Run.

Google may ask for permissions the first time. Approve them so the script can run inside your sheet.


Copy and paste this script

/**
 * Simple save-and-run Google Apps Script.
 *
 * What it does:
 * - Finds the input column named "company name"
 * - Cleans every company name
 * - Creates or updates a column called "cleaned company name"
 *
 * How to run:
 * 1. Open Google Sheet
 * 2. Extensions > Apps Script
 * 3. Paste this script
 * 4. Save
 * 5. Select cleanCompanyNames from the function dropdown
 * 6. Click Run
 */

function cleanCompanyNames() {
  const sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();

  const inputHeader = 'company name';
  const outputHeader = 'cleaned company name';

  const lastRow = sheet.getLastRow();
  const lastCol = sheet.getLastColumn();

  if (lastRow < 2) {
    throw new Error('No data found. Add company names under a header called "company name".');
  }

  const headers = sheet.getRange(1, 1, 1, lastCol).getDisplayValues()[0];

  const inputCol = findColumnByHeader(headers, inputHeader);

  if (inputCol === -1) {
    throw new Error('Could not find a column called "company name".');
  }

  let outputCol = findColumnByHeader(headers, outputHeader);

  if (outputCol === -1) {
    outputCol = lastCol + 1;
    sheet.getRange(1, outputCol).setValue(outputHeader);
  }

  const values = sheet.getRange(2, inputCol, lastRow - 1, 1).getDisplayValues();

  const cleanedValues = values.map(row => {
    return [cleanSingleCompanyName(row[0])];
  });

  sheet.getRange(2, outputCol, cleanedValues.length, 1).setValues(cleanedValues);

  Logger.log('Done. Cleaned ' + cleanedValues.length + ' company names.');
}

function cleanSingleCompanyName(value) {
  if (!value) return '';

  let name = String(value).trim();

  name = decodeHtmlEntities(name);
  name = extractNameFromEmailOrDomain(name);
  name = removeUrls(name);
  name = normalizeSeparators(name);
  name = removeLegalSuffixes(name);
  name = removeExtraSpaces(name);
  name = smartTitleCase(name);

  return name;
}

function extractNameFromEmailOrDomain(value) {
  let text = String(value).trim();

  const emailMatch = text.match(/^[^\s@]+@([a-zA-Z0-9.-]+\.[a-zA-Z]{2,})$/);
  if (emailMatch) {
    return domainToCompanyName(emailMatch[1]);
  }

  const domainOnlyMatch = text.match(/^(?:https?:\/\/)?(?:www\.)?([a-zA-Z0-9.-]+\.[a-zA-Z]{2,})(?:\/.*)?$/);
  if (domainOnlyMatch) {
    return domainToCompanyName(domainOnlyMatch[1]);
  }

  return text;
}

function domainToCompanyName(domain) {
  let host = String(domain).toLowerCase();

  host = host.replace(/^https?:\/\//, '');
  host = host.replace(/^www\./, '');
  host = host.split('/')[0];
  host = host.split('?')[0];

  const parts = host.split('.').filter(Boolean);

  if (parts.length === 0) return '';

  const commonSecondLevelTlds = ['co', 'com', 'net', 'org', 'ac', 'edu', 'gov'];

  let root;

  if (
    parts.length >= 3 &&
    parts[parts.length - 1].length === 2 &&
    commonSecondLevelTlds.includes(parts[parts.length - 2])
  ) {
    root = parts[parts.length - 3];
  } else if (parts.length >= 2) {
    root = parts[parts.length - 2];
  } else {
    root = parts[0];
  }

  return root.replace(/[-_]+/g, ' ');
}

function removeUrls(value) {
  return String(value)
    .replace(/https?:\/\/[^\s]+/gi, ' ')
    .replace(/www\.[^\s]+/gi, ' ')
    .replace(/[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}(\/[^\s]*)?/gi, ' ');
}

function normalizeSeparators(value) {
  return String(value)
    .replace(/&amp;/gi, '&')
    .replace(/\+/g, ' and ')
    .replace(/[_|\\/]+/g, ' ')
    .replace(/[-]+/g, ' ')
    .replace(/[.,;:!?()[\]{}"'`~*#@%^=<>]/g, ' ')
    .replace(/\s*&\s*/g, ' & ');
}

function removeLegalSuffixes(value) {
  let name = removeExtraSpaces(value);

  const suffixes = [
    'limited liability company',
    'private limited company',
    'public limited company',
    'proprietary limited',
    'company limited',
    'pvt ltd',
    'pte ltd',
    'pty ltd',
    'sdn bhd',
    'incorporated',
    'corporation',
    'limited',
    'llc',
    'llp',
    'lllp',
    'pllc',
    'ltd',
    'inc',
    'corp',
    'pvt',
    'pte',
    'pty',
    'plc',
    'lp',
    'pc',
    'pa',
    'co',
    'gmbh',
    'bv',
    'nv',
    'sarl',
    'sasu',
    'oyj',
    'oy',
    'ab',
    'aps',
    'kft',
    'zrt',
    'bhd'
  ];

  let changed = true;

  while (changed) {
    changed = false;

    for (const suffix of suffixes) {
      const regex = new RegExp('\\s+' + escapeRegex(suffix) + '$', 'i');
      const newName = name.replace(regex, '').trim();

      if (newName !== name) {
        name = newName;
        changed = true;
      }
    }
  }

  return name;
}

function smartTitleCase(value) {
  const brandWords = {
    '3m': '3M',
    'ai': 'AI',
    'api': 'API',
    'aws': 'AWS',
    'b2b': 'B2B',
    'b2c': 'B2C',
    'bbc': 'BBC',
    'crm': 'CRM',
    'fedex': 'FedEx',
    'github': 'GitHub',
    'h&m': 'H&M',
    'hp': 'HP',
    'ibm': 'IBM',
    'linkedin': 'LinkedIn',
    'mcdonalds': 'McDonalds',
    'nhs': 'NHS',
    'openai': 'OpenAI',
    'paypal': 'PayPal',
    'saas': 'SaaS',
    'seo': 'SEO',
    'tiktok': 'TikTok',
    'uk': 'UK',
    'usa': 'USA',
    'youtube': 'YouTube'
  };

  const smallWords = ['and', 'or', 'of', 'the', 'in', 'on', 'at', 'for', 'with', 'to', 'by'];

  const words = removeExtraSpaces(value).split(' ');

  return words.map((word, index) => {
    const lower = word.toLowerCase();

    if (brandWords[lower]) {
      return brandWords[lower];
    }

    if (word === '&') {
      return '&';
    }

    if (
      index > 0 &&
      index < words.length - 1 &&
      smallWords.includes(lower)
    ) {
      return lower;
    }

    if (/^[A-Z0-9]{2,4}$/.test(word)) {
      return word;
    }

    return lower.charAt(0).toUpperCase() + lower.slice(1);
  }).join(' ');
}

function findColumnByHeader(headers, targetHeader) {
  const normalizedTarget = normalizeHeader(targetHeader);

  for (let i = 0; i < headers.length; i++) {
    if (normalizeHeader(headers[i]) === normalizedTarget) {
      return i + 1;
    }
  }

  return -1;
}

function normalizeHeader(value) {
  return String(value)
    .toLowerCase()
    .replace(/[_-]+/g, ' ')
    .replace(/[^a-z0-9 ]/g, '')
    .replace(/\s+/g, ' ')
    .trim();
}

function decodeHtmlEntities(value) {
  return String(value)
    .replace(/&amp;/gi, '&')
    .replace(/&nbsp;/gi, ' ')
    .replace(/&quot;/gi, '"')
    .replace(/&#39;/gi, "'");
}

function removeExtraSpaces(value) {
  return String(value).replace(/\s+/g, ' ').trim();
}

function escapeRegex(value) {
  return String(value).replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
}

How to use it

  1. Put your raw company names under the column header:
company name
  1. Run:
cleanCompanyNames
  1. The script will create or update this column:
cleaned company name
  1. Your cleaned names will appear automatically.

Example output

company name cleaned company name
ACME INC. Acme
openai.com OpenAI
[email protected] HubSpot
THE NORTH FACE, INC. The North Face
salesforce.co.uk Salesforce
Stripe LLC Stripe

Best use cases

Use this when you need to clean company names for:

  • Cold email personalization
  • Lead list cleanup
  • CRM imports
  • Company deduplication
  • Outbound campaign prep
  • Google Sheets workflows
  • Data enrichment
  • Sales ops

Important note

This script is designed for a fast cleanup pass.

It will clean most company names well, but no automated cleaner is perfect.

Always review important records before using them in client work or high-volume campaigns.


Quick tip

For best results, keep the input column simple.

Good inputs:

OpenAI LLC
HubSpot Inc
stripe.com
[email protected]
The North Face, Inc.

Bad inputs:

HubSpot old lead list 2026
Stripe prospect exported from Apollo
Salesforce contact from US campaign

Clean input gives cleaner output.


Built for people who hate manual cleanup

If you work with lead lists, outbound systems, Google Sheets, CRM data, or cold email personalization, this will save you a lot of boring manual work.

Follow for more practical AI, outbound, GTM, and automation workflows:

@lifeofarjav

instagram.com/lifeofarjav

Related in Outbound & GTM

Outbound & GTM EMAIL: Cold Email Fix Framework Outbound & GTM Google X-Ray Formula For LinkedIn Founder Leads Outbound & GTM Google X-Ray Formula For Instagram Store Leads
← Back to Writing