Skip to content

Module 8: cast_titlecase

The cast_titlecase filter converts company and account names to proper title case — capitalizing the first letter of most words while handling the dozens of special cases that make company names tricky: legal suffixes (LLC, GmbH, Inc.), acronyms (AI, API, AT&T), name prefixes (McDonald, O’Neill), and English particles (of, the, and).

This is not the same as Liquid’s built-in capitalize filter, which only uppercases the very first character of the string. cast_titlecase is specifically designed for the kinds of names that live in Salesforce, Gainsight, HubSpot, and other CRMs.

Excel analogy: Excel’s =PROPER("ACME LLC") would give you “Acme Llc” — incorrectly lowercasing the legal suffix. cast_titlecase knows that “LLC” should stay uppercase, that “GmbH” has a specific casing, and that “McDonald” needs an internal capital.

A narration that says “Welcome to ACME LLC’s review” or “Welcome to Acme Llc’s review” looks unprofessional. cast_titlecase produces “Welcome to Acme LLC’s review” — which is correct and polished. When a narrator speaks “ACME LLC,” it sounds like shouting. Proper casing produces natural, professional audio.


{% raw %}
{{ contact_account_name | cast_titlecase }}
{% endraw %}

That’s it. One filter handles all the complexity. Let’s look at what it does internally.


The filter always normalizes ALL-CAPS input first, then applies title casing rules:

{% raw %}
{{ "ACME CORP" | cast_titlecase }} → Acme Corp
{{ "GLOBAL SOLUTIONS GROUP" | cast_titlecase }} → Global Solutions Group
{% endraw %}

Common particles — of, the, and, at, for, in, by — are lowercased when they appear in the middle of a name. They’re still capitalized if they’re the first or last word:

{% raw %}
{{ "BANK OF AMERICA" | cast_titlecase }} → Bank of America
{{ "THE HOME DEPOT" | cast_titlecase }} → The Home Depot
{{ "BREAD AND BUTTER LLC" | cast_titlecase }} → Bread and Butter LLC
{% endraw %}

Legal suffixes and well-known acronyms stay in all caps:

LLC, LLP, LP, PLC, AB, AG, SA, SE, NV, BV, SAS, US, UK, EU, AI, API, IP, R&D, AT&T

{% raw %}
{{ "ACME LLC" | cast_titlecase }} → Acme LLC
{{ "AI SOLUTIONS GROUP" | cast_titlecase }} → AI Solutions Group
{{ "AT&T SERVICES LLC" | cast_titlecase }} → AT&T Services LLC
{% endraw %}

Common corporate suffixes are cased in their conventional form:

Inc, Inc., Corp, Corp., Ltd, Ltd., GmbH, Oy, Co, Co., Company, Corporation, Limited

{% raw %}
{{ "ACME GMBH" | cast_titlecase }} → Acme GmbH
{{ "SMITH CORPORATION" | cast_titlecase }} → Smith Corporation
{{ "JONES LTD." | cast_titlecase }} → Jones Ltd.
{% endraw %}

Names starting with “Mc” or “Mac” followed by a capital get the correct internal capitalization:

{% raw %}
{{ "MCDONALD CORP" | cast_titlecase }} → McDonald Corp
{{ "MCCARTHY HOLDINGS" | cast_titlecase }} → McCarthy Holdings
{% endraw %}

Names with apostrophe prefixes are handled correctly:

{% raw %}
{{ "O'NEILL MEDIA LLC" | cast_titlecase }} → O'Neill Media LLC
{{ "D'ARCY HOLDINGS INC." | cast_titlecase }} → D'Arcy Holdings Inc.
{{ "L'ENFANT PARTNERS" | cast_titlecase }} → L'Enfant Partners
{% endraw %}

Each part of a hyphenated name is capitalized individually:

{% raw %}
{{ "SMITH-JONES LLC" | cast_titlecase }} → Smith-Jones LLC
{% endraw %}

Welcome slide opening:

{% raw %}
Welcome to {{ contact_account_name | cast_titlecase | cast_apostrophe }}
Executive Business Review.
{% endraw %}

For "BANK OF AMERICA"Welcome to Bank of America's Executive Business Review. For "AT&T SERVICES LLC"Welcome to AT&T Services LLC's Executive Business Review. For "O'NEILL MEDIA LLC"Welcome to O'Neill Media LLC's Executive Business Review.

Benchmark comparison:

{% raw %}
{%- assign company = contact_account_name | cast_titlecase -%}
{{ company }} outperformed 80% of companies in your industry segment.
{% endraw %}

For "ACME GMBH"Acme GmbH outperformed 80% of companies in your industry segment.


Here’s a comprehensive table showing input → output for cast_titlecase:

Input (CRM value) Output
"ACME LLC" Acme LLC
"BANK OF AMERICA" Bank of America
"ACME GMBH" Acme GmbH
"AT&T SERVICES LLC" AT&T Services LLC
"O'NEILL MEDIA LLC" O'Neill Media LLC
"MCDONALD CORP" McDonald Corp
"D'ARCY HOLDINGS INC." D'Arcy Holdings Inc.
"AI SOLUTIONS GROUP" AI Solutions Group
"SMITH-JONES LLC" Smith-Jones LLC
"GLOBAL SOLUTIONS GROUP" Global Solutions Group

The filter handles English particles (of, the, and, etc.) correctly, but non-English particles (van, der, de, la, le) are capitalized rather than lowercased:

{% raw %}
{{ "VAN DER MEER GROUP" | cast_titlecase }} → Van Der Meer Group
{% endraw %}

The conventional spelling would be “Van der Meer Group” (lowercase der), but cast_titlecase capitalizes it. Similarly:

{% raw %}
{{ "DE LA CRUZ PARTNERS" | cast_titlecase }} → De La Cruz Partners
{% endraw %}

Instead of “de la Cruz Partners.” If your customer base includes many names with non-English particles, be aware of this behavior.

⚠️ cast_titlecase will error if the input is nil, empty, or contains only whitespace. Always chain default before it:

{% raw %}
{{ contact_account_name | default: "your company" | cast_titlecase }}
{% endraw %}

Using capitalize instead of cast_titlecase for company names:

{% raw %}
{{ "ACME LLC" | capitalize }} → ACME LLC (unchanged — first char was already uppercase)
{{ "acme llc" | capitalize }} → Acme llc (only first letter, "llc" stays lowercase)
{% endraw %}

Use cast_titlecase for company names:

{% raw %}
{{ "ACME LLC" | cast_titlecase }} → Acme LLC
{{ "acme llc" | cast_titlecase }} → Acme LLC
{% endraw %}

Applying cast_titlecase to a nil field:

{% raw %}
{{ contact_account_name | cast_titlecase }}
{% endraw %}

Errors if the field is nil or empty.

Always default first:

{% raw %}
{{ contact_account_name | default: "your company" | cast_titlecase }}
{% endraw %}

Applying cast_titlecase to non-company text (like sentences):

{% raw %}
{{ "WELCOME TO YOUR REVIEW" | cast_titlecase }} → Welcome to Your Review
{% endraw %}

This works but may produce unexpected results — cast_titlecase is optimized for company names, not general text. For general text, use downcase | capitalize or write the text normally.


Exercise: You have three account names:

  • "JOHNSON AND JOHNSON"
  • "mcdonald's restaurants llc"
  • "" (empty string)

Write Liquid that safely displays each one with cast_titlecase, with a fallback for the empty one.

Click to reveal the answer
{% raw %}
{{ "JOHNSON AND JOHNSON" | cast_titlecase }}
→ Johnson and Johnson
{{ "mcdonald's restaurants llc" | cast_titlecase }}
→ McDonald's Restaurants LLC
{{ "" | default: "Unknown Company" | cast_titlecase }}
→ Unknown Company
{% endraw %}

Key details:

  • “and” is lowercased as an English particle
  • “mcdonald’s” gets the Mc prefix handling
  • “llc” is recognized and uppercased to “LLC”
  • The empty string gets a default before cast_titlecase to avoid an error

In Module 9, you’ll learn about cast_apostrophe — the filter that adds grammatically correct possessives to any name, handling both “Jason’s” and “James’” automatically.


📖 Official documentation: