Skip to content
Salesforce Dictionary - Free Salesforce GlossarySalesforce Dictionary
DictionaryLLength
Core CRMAdvanced

Length

Length in Salesforce is the field attribute that sets the maximum number of characters or digits a field can hold.

§ 01

Definition

Length in Salesforce is the field attribute that sets the maximum number of characters or digits a field can hold. It appears on Text, Long Text Area, Rich Text Area, Number, Currency, Percent, Phone, Email, URL, and similar field types. When an admin creates a custom field, the Length entry is the sizing decision that shapes validation, integration limits, search behavior, and storage.

The word also shows up in two other places. LEN() is a formula function that returns the character count of a string, and every standard field carries a fixed length you cannot change. Account.Name allows 255 characters, Opportunity.Name 120, and Contact.LastName 80. Apex and integrations that exceed those limits hit a STRING_TOO_LONG error, so the Length attribute is something both admins and developers have to plan around.

§ 02

How Length shapes each field type

Text fields and the 255-character boundary

A standard Text field accepts up to 255 characters, and you set the exact ceiling when you create the field. The 255 mark is more than a sizing number. It is the line between two very different field types. Text stays searchable, usable in formulas, and available as a report filter. The moment your content needs more than 255 characters, Salesforce moves you to a Long Text Area or Rich Text Area, and those behave differently. So a Length decision on a Text field is partly a behavior decision. Pick 200 for a short label that people will search on, and you keep full indexing and formula support. Pick 255 because you are unsure, and you are still inside the same field type with the same capabilities. The trouble starts only when real content pushes past 255 and you have to convert the field. That conversion changes search, formula, and filtering behavior in one step, so it pays to size Text fields against the longest value you actually expect rather than the shortest one that looks tidy in a layout.

Long Text Area and Rich Text Area limits

Long Text Area and Rich Text Area fields go well beyond Text. The maximum length is 131,072 characters (128 KB), the default when you create one is 32,768 characters (32 KB), and the minimum you can set on a custom field is 256. You type the limit you want at field creation, and you can raise it later up to the ceiling. Two limits catch people off guard. First, each object can hold a combined 1,638,400 characters across all of its Long Text Area and Rich Text Area fields, so a dozen large fields on one object can run you out of room. Second, Rich Text Area counts the hidden HTML markup against the limit. Bold text adds the opening and closing tags, which is roughly seven extra characters for one short phrase, and that overhead grows with heavy formatting. A field that looks half full in the editor can be closer to its limit than it appears. Plan the Length on these fields with the markup and the per-object cap in mind, not just the visible text.

Number, Currency, and Percent precision

Numeric fields express Length as two parts. You set the total number of digits and the number of decimal places, written as a pair like (18, 2). The digits to the left of the decimal point are the total minus the decimal places, so (18, 2) gives you 16 digits before the point and 2 after. Salesforce supports up to 18 total digits on these fields, and Currency and Percent follow the same model. There is a behavior worth knowing. The Length and Decimal Places you set are enforced when a person edits the record in the Salesforce UI. Apex and the API can write values with more decimal places than the field defines, because the platform stores Number and Percent values using a Double under the hood. The display rounds to your definition, but the fuller value can sit in the database. If exact rounding matters for reporting or downstream systems, do not rely on the field definition alone. Round explicitly in your code or with a formula so the stored value matches what you expect.

Increasing Length is safe, decreasing is risky

You can increase a custom field Length without losing data. Going from a 40-character Text field to 80 is a routine change, and existing values stay intact. Decreasing Length is the dangerous direction. Salesforce checks every existing value at save time, and if any record holds more characters than the new shorter limit, the platform blocks the change rather than truncating your data. That guard is helpful, but it means a shrink in production is rarely a quick edit. You first need to find the rows that exceed the proposed limit, then decide whether to shorten those values, move them elsewhere, or abandon the change. On a large object that is a real data audit, often backed by a report or a SOQL query that filters on LEN of the field. The practical lesson is to size fields generously the first time. The cost of a slightly oversized field is close to nothing, while the cost of an undersized one is a migration you scheduled because a length guess was too tight.

Standard field lengths you cannot change

Every standard field ships with a fixed length, and you cannot edit it. Account.Name is 255 characters, Opportunity.Name is 120, Contact.LastName is 80, and many email fields cap at 80. These numbers are documented in the Object Reference, and they are the same in every org regardless of edition. This matters most at integration time. When an external system pushes data into Salesforce, its values have to fit the target field, or the insert fails with STRING_TOO_LONG. A source system with a 100-character company name will overflow a field that maps to a shorter standard field, and the error surfaces in the middle of a load rather than during design. Apex and Flow run into the same wall on DML. The fix is to check the standard field lengths during mapping, then truncate or transform oversized source values before they reach the platform. Custom staging fields sized to match the source, with logic that trims to the standard length on the way in, keep these loads from breaking.

Length in formulas with LEN()

LEN(text) is the formula function that returns how many characters a string contains. It counts characters rather than bytes, so a multibyte Unicode character counts as one. You will reach for it in two common spots. In a validation rule, LEN lets you enforce limits the field attribute cannot express on its own, such as requiring a code to be exactly 10 characters or blocking a description longer than a set count. In a formula field, LEN can drive logic that depends on how long an input is. A worked example helps. Suppose a Reference Code field should always be 8 characters. The field Length attribute caps the maximum at 8, but it does not stop someone entering 3 characters. A validation rule with the condition LEN(Reference_Code__c) <> 8 enforces the exact size and shows a clear error when the entry is wrong. This is the division of labor to remember. The Length attribute sets the ceiling, and LEN inside a validation rule enforces the rules the ceiling alone cannot, including minimum length and fixed formats.

Search, indexing, and External ID sizing

Length quietly shapes search. Text fields up to 255 characters are indexed and participate in standard search. Long Text Area content above that boundary is not indexed the same way, so choosing a longer field type to be safe can cost you findability. If users need to search the content of a field, keeping it inside the Text range is often the better call. External ID and Unique fields add their own sizing judgment. External IDs are usually Text fields, and a common choice is 18 characters to match a Salesforce record Id or longer to hold a UUID-style key from another system. Size these too small and you risk collisions, especially when an upstream system concatenates several identifiers into one key. Unique fields enforce no duplicates across the object, so an undersized Unique External ID can reject legitimate records or, worse, force a redesign mid-project. Match the Length to the real shape of the external key, with a little headroom, and these integration fields stay reliable.

§ 03

How to set Length when creating a custom field

You set Length while creating a custom field in Setup. The steps below show where the attribute lives for a Text field and what each related option controls.

  1. Open Object Manager and start a new field

    In Setup, go to Object Manager, pick the object, open Fields and Relationships, and click New. This opens the new custom field wizard.

  2. Choose the field type

    Select a type such as Text, Number, or Long Text Area. The Length input that appears next depends on the type you pick, so choose the type that matches your data first.

  3. Enter the Length value

    For Text, type a number from 1 to 255. For Long Text Area or Rich Text Area, type a limit up to 131,072. For Number, Currency, or Percent, set the total digits and decimal places.

  4. Set visibility and save

    Apply field-level security, add the field to page layouts, then save. The field is created with the Length you entered, which you can raise later from the same field detail page.

Length (Text)remember

The maximum character count for a Text field, from 1 to 255. Above 255 you must use a Long Text Area or Rich Text Area instead.

Length (Number)remember

The total number of digits for a numeric field, up to 18, split between the integer side and the decimal places you define.

Decimal Placesremember

For Number, Currency, and Percent, the count of digits shown after the decimal point. It is subtracted from the total Length to size the integer side.

Long Text Area limitremember

The character ceiling for a Long Text Area or Rich Text Area, with a default of 32,768, a minimum of 256, and a maximum of 131,072.

Gotchas
  • Decreasing a field Length is blocked if any existing record holds a value longer than the new limit, so audit data before you try to shrink a field.
  • Rich Text Area counts hidden HTML tags toward its limit, so a formatted field reaches its ceiling faster than the visible text suggests.
  • Standard field lengths are fixed and cannot be changed, so plan integrations around limits like Account.Name at 255 and Contact.LastName at 80.

Prefer this walkthrough as its own page? How to Length in Salesforce, step by step

§

Trust & references

Sources

Cross-checked against the following references.

Official documentation

Straight from the source - Salesforce's reference material on Length.

Was this entry helpful?
Help us write better definitions. Quick reactions or detailed edit suggestions.

About the Author

Dipojjal Chakrabarti is a B2C Solution Architect with 29 Salesforce certifications and over 13 years in the Salesforce ecosystem. He runs salesforcedictionary.com to help admins, developers, architects, and cert/interview candidates sharpen their fundamentals. More about Dipojjal.

§

Test your knowledge

Q1. What does the Length attribute define when an admin creates a Text or Number custom field?

Q2. What happens to a Text field's search and formula behavior once its Length exceeds 255 characters?

Q3. Why is decreasing a field's Length riskier than increasing it on a production object?

§

Discussion

Loading…

Loading discussion…