Salesforce Dictionary — Free Salesforce GlossarySalesforce Dictionary

Custom Labels

Administration🟢 Beginner

Definition

Custom Labels in Salesforce are custom text values that can be accessed from Apex code, Visualforce pages, Lightning components, and other platform features. They support translation into multiple languages, making them essential for building multilingual applications. Administrators create Custom Labels in Setup with a name, value, and optional translations, and developers reference them in code using System.Label.labelName.

Real-World Example

At their company, an admin at Redwood Financial leverages Custom Labels to ensure the Salesforce org runs smoothly and securely. They configure Custom Labels during a scheduled maintenance window, test it in a sandbox first, and then deploy to production. The result is tighter security and a more streamlined experience for all 200 users in the org.

Why Custom Labels Matters

Custom Labels in Salesforce are text values created in Setup that can be referenced from Apex code, Visualforce pages, Lightning components, and other platform features. Each label has a name (the identifier used in code), a value (the actual text), an optional category for organization, and importantly, support for translations into multiple languages. Developers reference labels in Apex as System.Label.labelName and in Visualforce as {!$Label.labelName}, with the platform automatically returning the value in the user's language if a translation exists.

Custom Labels are the standard way to externalize user-facing text from code, which is essential for multilingual applications and generally good practice even for single-language apps. Hardcoding text in code creates maintenance problems; using Custom Labels makes text changes a configuration task rather than a code change. For multilingual apps (common in global enterprises), Custom Labels combined with the Translation Workbench let you translate the entire UI without touching code, making localization significantly cheaper and faster.

How Organizations Use Custom Labels

  • Redwood FinancialUses Custom Labels for every user-facing string in their Apex and Lightning code. When they expanded into Spanish-speaking markets, they translated the labels through the Translation Workbench and the entire UI appeared in Spanish for Spanish-speaking users.
  • NovaScaleCentralizes error messages as Custom Labels so the support team can update them without a developer deployment. Simple wording changes now take minutes instead of requiring a code release.
  • Vertex GlobalStandardized on Custom Labels during a code review project. Before the review, hardcoded strings were scattered throughout the codebase; after, every user-facing string was a Custom Label reference that could be updated or translated independently.

🧠 Test Your Knowledge

1. What are Custom Labels?

2. How are Custom Labels referenced from Apex?

3. Why use Custom Labels instead of hardcoded strings?

See something that could be improved?

Suggest an Edit