Skip to main content

Why are large numbers rounded when I parse JSON in the API Connector?

Numbers with more than 16 digits may be rounded when returned as JSON from an API call. This is a limitation of JavaScript's JSON.parse function, not Bubble itself.

Written by Sofia Maconi

When an API call returns a number with more than 16 digits, the value stored in Bubble may be rounded. This is a limitation of JavaScript's JSON.parse function — very large integers can't be represented with full precision — and isn't specific to Bubble.

What you might notice

  • An API call that returns a number with more than 16 digits stores a slightly different value than expected

  • The number appears rounded up or down compared to the original

Workaround

If you control the API endpoint, return the large number as a string (wrap it in quotation marks in your API response) rather than a numeric value. Bubble will store it as text without attempting to parse it as a number, preserving the exact value.

This is a limitation of how JavaScript's JSON.parse function handles large integers. You can read more about it here.

Did this answer your question?