Write a Javascript Cost Calculator for Stripe's Graduated Pricing

PUBLISHED: AUG 25, 2022 | 221 words, 2 minute read — SOFTWARE DEVELOPMENT

Calculating the total cost of a graduated pricing scheme is a PITA if you have to do it more than once - and Stripe’s Price dashboard unfortunately doesn’t have any tooling to help you. Instead of doing it by hand every time, let’s write a Javascript calculator to do it for us.

Why 🔗︎

Plenty of reasons you’d want to test out potential pricing scenarios before they actually happen - getting quotes for prospective customers, comparison with competitors, checking the impact of discount codes, etc. There’s a reason sites exist like Serverless Cost Calculator for AWS .

Wait, what is graduated pricing 🔗︎

Stripe offers a graduated pricing model under Usage-based Billing , e.g.:

Marginal UnitsUnit Price ($)
For the first5$10
For the next10$7
For the next$5

Graduated Pricing Calculator 🔗︎

disclaimer: for now you can only use the hardcoded tiers on this page - but feel free to remix it for your own usecase! Copy the code below and edit pricingTiers to update the calculator. The function can be copied directly into your browser console or into anywhere that runs Javascript.


Total Users:
Total Cost: $0

Marginal Cost Breakdown


The Code 🔗︎

HAHAHUGOSHORTCODE62s2HBHB

See Also