STRING_TOO_LONG in Salesforce: what it means and how to fix it
Short answer: STRING_TOO_LONG means a value you sent to a text-based field has more characters than that field allows. Salesforce doesn't trim it for you by default; it rejects the row and reports the field and its maximum length, so the fix is either a shorter value or a longer field.
Every text-based field in Salesforce has a maximum length: Text, Text Area, Long Text Area, Rich Text, and also Email, Phone and URL fields. If a value has more characters than the field's limit, Salesforce rejects the row instead of saving a shortened copy:
STRING_TOO_LONG: Project Name: data value too large: Riverside Medical Center North Campus Expansion Phase Two (max length=40)
The error gives you the field label, the value that didn't fit and the limit, which is everything you need to decide what to change.
Why it happens
- Field lengths differ between orgs. A custom field might be 255 characters in production and 80 in a sandbox, or a managed package may define a shorter field than the one you're mapping from.
- Mapping into a smaller field. Loading a Long Text Area from the source system into a plain Text field, or a free-text description into a short code field.
- Concatenated values. Integrations that join first name, last name and company, or append IDs and timestamps to make values unique, can push a value just past the limit.
- Hidden characters. Line breaks, tabs, HTML from rich text editors, and padding from fixed-width exports all count toward the limit.
- Unexpected source values. One customer with an unusually long company name or address line is enough to fail a row that's fine for everyone else.
How to fix it
- Read the limit from the message and compare it with the length of the source value.
- Decide which side is wrong. If the data is legitimately long, widen the custom field in Setup; Text fields go up to 255 characters, and longer values belong in a Long Text Area.
- Truncate deliberately when the tail doesn't matter, for example in sandbox test data, and prefer cutting at a word boundary over mid-word.
- Clean the value first. Trim whitespace, remove markup when loading into plain text, and collapse repeated line breaks.
- Fix the mapping if a long source field is being pointed at a short target field by mistake.
- Align field definitions across orgs, so sandboxes and production agree on lengths before you copy data between them.
How Syntharil handles it
Syntharil classes STRING_TOO_LONG as a data format error, because the generated value was too large for the field rather than the schema being wrong. Its seeding engine reads each field's maximum length from the org and cuts generated text to fit it, whether the value came from the default text generators, the semantic-type catalog or an AI-built field profile. When a field must hold unique values, the uniqueness suffix is counted inside the limit, so making a value unique never pushes it over. Rows that still fail are listed with Salesforce's message. During replication, schema harmonization is an option you turn on per run: when it's enabled, any custom field that is longer in the source than in the target is widened on the target before data is copied, and masked emails, URLs and redacted values are clipped to the target field's length.
FAQ
Where does STRING_TOO_LONG show the field's maximum length?
At the end of the message, as (max length=N). The field's label appears before the phrase data value too large, so the error tells you both which field overflowed and how many characters it accepts.
Can Salesforce truncate long strings instead of raising STRING_TOO_LONG?
Yes, in some APIs. The SOAP API accepts an AllowFieldTruncationHeader, and Apex has Database.DMLOptions.allowFieldTruncation, both of which shorten oversized values instead of failing. Whether your loading tool exposes the option depends on which API it uses.
Why does STRING_TOO_LONG happen in a sandbox but not in production?
The two orgs can define the same field with different lengths. If someone shortened a custom field in the sandbox, or the sandbox was refreshed before production widened it, production data that fits there overflows in the sandbox.
Is it safe to increase a text field's length to fix STRING_TOO_LONG?
Increasing the length of a custom Text field is normally a safe metadata change. Decreasing it is riskier, because existing values that no longer fit can be cut short. Standard field lengths are fixed and can't be changed.
Do line breaks and HTML count toward the STRING_TOO_LONG limit?
Yes. Field limits count characters in the stored value, so newline characters in a Text Area and the markup in a Rich Text field use up the limit just like visible text.