Skip to content

Instantly share code, notes, and snippets.

@drmzio
Created August 5, 2021 18:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save drmzio/8032709490fa70413a0a50cf54d69d48 to your computer and use it in GitHub Desktop.
Save drmzio/8032709490fa70413a0a50cf54d69d48 to your computer and use it in GitHub Desktop.
Stripe convert amount to float
/**
* Converts Stripe amounts like 25000 to the currency amount like "250.00" in string format.
* @param amount - A stripe whole number amount.
* @return string
*/
export const toFloatString = (amount) => {
const total = (amount / 100)
.toLocaleString('en-US', { style: 'currency', currency: 'usd' })
.replace('$', '');
return total.toString();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment