Precision Matters: Mastering Decimal Formatting in HubSpot's CRM API
Ever pulled data from HubSpot's CRM API and been overwhelmed by a sea of decimal places? You're not alone! A HubSpot Community member recently encountered this when retrieving deal data using the /crm/v3/objects/0-3/search API. They were looking to limit the decimal places for properties like hs_deal_stage_probability and hs_projected_amount.
Here's a snippet of the API request they were using:
{
"after": "0",
"limit": 100,
"sorts": ["lastmodifieddate"
],"properties": [
"deal_customer_number",
"opp_account_number",
"opportunity_id",
"closed_lost_reason",
"closedate",
"createdate",
"dealname",
"dealstage",
"description",
"product_type",
"source",
"hs_deal_stage_probability",
"hs_projected_amount",
"hubspot_owner_id",
"expected_close_date",
"forecast",
"gm"],
"filterGroups": [
{"filters": [
{"propertyName": "hs_lastmodifieddate",
"value": "2026-03-03T16:50:02Z",
"operator": "GT"
},{"propertyName": "pipeline",
"value": "default",
"operator": "EQ"}]}]}
And here's an example of the data they were receiving, showing the excessive decimal places:
"id": "56284170888",
"properties": {
"closed_lost_reason": null,
"closedate": null,
"createdate": "2026-02-05T13:49:33Z",
"deal_customer_number": "1118276",
"dealname": "01.16.2026 1220 EXHIBITS AXS 195959",
"dealstage": "qualifiedtobuy",
"description": "01.16.2026 1220 EXHIBITS AXS 195959",
"expected_close_date": "2026-05-01",
"forecast": "11950",
"gm": ".4054",
"hs_deal_stage_probability": "0.299999999999999988897769753748434595763683319091796875",
"hs_lastmodifieddate": "2026-03-03T18:02:19.199Z",
"hs_object_id": "56284170888",
"hs_projected_amount": "3584.999999999999867328348557293793419376015663146972656250",
"hubspot_owner_id": "32613012",
"opp_account_number": "61276",
"opportunity_id": "62864",
"product_type": null,
"source": null
},
The Solution: Formatting After Retrieval
Unfortunately, the HubSpot API doesn't offer built-in formatting options for numeric values directly in the API request. As one respondent in the community pointed out, the API response will always return the raw values. This means you'll need to handle the formatting on your end, after you've retrieved the data.
How to Format Numeric Strings in JavaScript
The suggested solution involves extracting the values from the API response and then processing them using code. Here's a simple JavaScript example to round the hs_deal_stage_probability value to two decimal places:
const probability = parseFloat(deal.properties.hs_deal_stage_probability);
const roundedProbability = Number(probability.toFixed(2));
This code snippet first converts the string value to a floating-point number using parseFloat(). Then, it uses the toFixed(2) method to round the number to two decimal places. Finally, Number() is used to ensure the result is a number data type.
Applying the Solution
You can adapt this approach to other properties like hs_projected_amount and adjust the number of decimal places as needed. Remember to implement this formatting logic within your application or integration, after you've received the data from the HubSpot API. If you are building a web shop builder, for example, you'll want to format currency values appropriately before displaying them to customers.
ESHOPMAN Team Comment
We agree with the community's assessment: post-retrieval formatting is the way to go. While it would be convenient to have formatting options directly in the API, handling it in your code gives you more control and flexibility. For e-commerce applications, consistent and clean number formatting is crucial for a professional user experience. Consider creating reusable functions to handle formatting across your application.
Ultimately, while it adds a step to your workflow, formatting numbers after retrieving them from the HubSpot API allows for maximum control over presentation. It ensures your data is clean, consistent, and user-friendly, whether you're displaying it in a report or using it in your e-commerce web shop.