Try Serpent Free

How to fix STRING_TOO_LONG in Salesforce deployments

A value written to a text, picklist, or email field exceeds the maximum length defined on that field.

Surfaces during: runtime DML, in data loads, Apex tests, and Flow or Apex string-building logic

What it means

STRING_TOO_LONG means a record insert or update is trying to write more characters into a field than its metadata allows. Standard text fields, picklists, and email fields all have a defined maximum length, and Salesforce enforces it strictly: truncation never happens silently.

Standard Text fields cap at 255 characters maximum; anything longer needs a Long Text Area or Rich Text field instead, which is why this error is a common signal that a field was simply the wrong type for the content it's now being asked to hold.

Diagnosis

Common causes

Data migrated from a system with looser limits
Source data, often from a legacy CRM or spreadsheet, has values longer than the target field's configured length.
Field length shrunk after data already existed
A field's max length was reduced in a later deployment, and existing or incoming data no longer fits.
Concatenated values in Apex or Flow
A formula, Flow, or Apex trigger builds a string by joining multiple fields, and the combined result exceeds the target field's limit.

The fix

  1. Increase the field length if the business case supports it
    Raise the field's max length in metadata if the longer values are legitimate and the field type allows it.
  2. Validate at the point of entry
    Add a Flow or Apex guard that trims or rejects oversized values before they reach the DML operation.
    String safeValue = rawValue.length() > 255
        ? rawValue.left(255)
        : rawValue;
  3. Audit migrated data against the target schema
    Compare source data lengths to target field limits before a migration, not after the load fails.
In practice

How Serpent prevents this

Serpent's CI pipelines run a field-length validation pass before a data load reaches a shared org, so an oversized value fails fast in a pipeline step instead of mid-deployment. See the Salesforce deployment error library.

Metadata and data in one deployment flow in Serpent

Prevention

Choose Long Text Area over Text for any field that might grow
Default free-text fields with uncertain future content to a long text area rather than a 255-character Text field, since widening later is more disruptive than starting wider.
Cap concatenated strings at the destination field's limit, not the source's
Truncate explicitly in Apex or Flow whenever a formula joins multiple fields into one, using the destination field's actual length as the bound.
Profile source field lengths before every migration
Run a MAX(LENGTH(column)) check against source data for every text field being migrated, and compare it to the destination field's max length before the load.
Common questions

STRING_TOO_LONG, answered

Does STRING_TOO_LONG apply to rich text and long text area fields too?
Long text areas and rich text have their own much higher limits and their own error, TEXT_AREA_LENGTH_EXCEEDED. STRING_TOO_LONG covers standard text, picklist, and email fields.
What is the maximum length for a standard Text field?
255 characters is the ceiling for a standard custom Text field; anything longer requires switching the field to Long Text Area or a similar type designed for larger content.
Does Salesforce count multi-byte characters differently for this limit?
No. The character limit is based on the number of characters, not bytes, so multi-byte Unicode characters (like many non-Latin scripts) count the same as single-byte ASCII characters toward the limit.

Start free. No credit card, no install, no commitment.

Set up in under 15 minutes. No DevOps hire needed.

Curious about faster shipping before you dive in? Let's talk

Commitment free!