The short answer
If the native Format data action is unavailable, first consider validating the source field or using a branch for a small fixed mapping. A connected-app code action can handle more specific transformations. Return a clear result, handle unknown input explicitly, and map the output into a separate property-update step.
Check the native option first
HubSpot’s documentation lists Format data for Data Hub Professional and Enterprise. It covers common transformations and explains how to use the result in a subsequent action. Check the current documentation and your account before adding another tool.
An installed app does not grant access to HubSpot workflow features your account lacks. If you use Turbyn, confirm the workflow-access requirements as well.
Choose the smallest useful fix
Validate upstream. If you control the source, a constrained field can prevent inconsistent values from entering the CRM.
Use a branch. A few known values may be clearer as explicit workflow branches.
Clean a historical dataset separately. A one-off correction may not need an always-running action. Preserve a backup and review changes before import.
Use code. This fits repeatable transformations with business-specific rules or a compatible parsing library.
A complete normalization example
Suppose a workflow receives a country value from a legacy form. This Turbyn JavaScript handler recognizes a small, explicitly supported set of US aliases. It is not a global country parser.
exports.main = async (event) => {
const raw = event.inputs?.country;
const value = typeof raw === "string" ? raw.trim().toUpperCase() : "";
const aliases = new Set(["US", "USA", "UNITED STATES"]);
const recognized = aliases.has(value);
return {
text: recognized ? "US" : "",
boolean: recognized,
status: recognized ? "normalized" : "review",
};
};
Synthetic test event:
{ "inputs": { "country": " usa " } }
Expected returned JSON:
{ "text": "US", "boolean": true, "status": "normalized" }
In the workflow, branch on the boolean output first. Only use text to update the property when the value was recognized. Route false results for review and preserve the original property. The status value remains available in the returned JSON.
Test the rule, not just the happy path
| Input | Expected behavior |
|---|---|
" usa " |
Normalize to US. |
"United States" |
Normalize to US. |
"Canada" |
Review; this example does not handle it. |
"", null or a missing value |
Review; do not overwrite the record. |
Add aliases deliberately, with tests. A transformation should not guess a person’s country, rewrite their name according to one culture’s casing rules, or discard an extension from a phone number without a policy.
Use a parser for more complex formats
For international phone numbers, start with the phone-normalization recipe and choose a default-country policy. For dates, define business days and calendar boundaries before calculating.
Finally, verify the saved record, not just the code’s return value. A correct transformation paired with the wrong output mapping still produces the wrong workflow.
Sources and references
Source documentation checked for this update. Availability can vary by subscription and account.