How to Calculate Net Revenue Retention (NRR) from Stripe
Stripe API · Updated 19 November 2026
TL;DR
Stripe does not return net revenue retention or gross revenue retention. Normalize each subscription to one month, then keep the customers who had MRR at periodStart. NRR divides their ending MRR by that starting MRR. The ending figure is starting MRR minus churned MRR minus contraction MRR plus expansion MRR. GRR stops before the expansion term, so it stays at or below 100%. New MRR and reactivation MRR are a different report.
The churn rate glossary and the MRR glossary are the definitions. How to calculate MRR from the Stripe API is the monthly normalizer. How to calculate churn rate from Stripe is the same starting book, read as a loss rate. This page reads it as retention. A single CSV can be normalized in the browser with the Stripe MRR CSV calculator. That page does not return NRR. The SaaS metrics dashboard template is $59 once. Its overview does not compute NRR. The live demo uses sample data.
- License
- $59 once
- Refund
- 7-day no-questions refund
- Stack
- Next.js 16, shadcn/ui, Recharts, Postgres, Drizzle, Clerk, optional Stripe
NRR, GRR, and the lines inside them
Net revenue retention answers one question: of the recurring revenue you had at the start of the window, how much of it is still there at the end, after upgrades and downgrades. Gross revenue retention asks the same question and ignores upgrades. Both rates use the starting book as the denominator. Customers who arrive during the window are not retained. They were not there to retain.
| Rate | Formula |
|---|---|
| Net revenue retention (NRR) | (Starting MRR − churned MRR − contraction MRR + expansion MRR) / starting MRR |
| Gross revenue retention (GRR) | (Starting MRR − churned MRR − contraction MRR) / starting MRR |
| Gross MRR churn | (Churned MRR + contraction MRR) / starting MRR, which is 1 − GRR |
| Net MRR churn | (Churned MRR + contraction MRR − expansion MRR) / starting MRR, which is 1 − NRR |
Churned MRR is the starting MRR of customers who are gone at the end. Contraction is the decrease for customers who stay. Expansion is the increase for customers who were already in the starting book, including a second subscription on that same customer. New MRR is a customer who was absent at the start. Reactivation MRR is a customer who was absent at the start and whose earlier subscription had already ended. Those two lines sit beside the rates. When starting MRR is zero, both rates are undefined. Dividing by zero is not 0% and it is not an infinite retention rate.
GRR cannot exceed 100% under this formula when each ending amount is zero or positive, because the numerator drops expansion and does not count an ending balance above the start. NRR can exceed 100% when expansion is larger than churned MRR plus contraction MRR. That is the same case as a negative net MRR churn. The churn guide reports the loss rates. This page reports the retention rates on that book.
- Write down NRR and GRR before you touch Stripe
- Normalize each subscription item to one month
- Split starting, expansion, contraction, and churned MRR
- List subscriptions and events with auto-pagination
- Query monthly snapshots when the window is older than the Events API
- Say whether the rate is one period or one cohort
Worked example, labeled as an example
Every figure in this section is hypothetical. It is example data for January 2026, from 2026-01-01T00:00:00.000Z to 2026-02-01T00:00:00.000Z, passed through calculateNetRevenueRetentionFromListedSubscriptions. It is separate from the public demo, from any customer account, and from the Stripe documentation example further down.
| Customer | What the row is | MRR at 1 Jan | MRR at 1 Feb |
|---|---|---|---|
| Keep | $100 every month. No subscription event in January. | $100.00 | $100.00 |
| Downgrade | 2 × $20 on 1 January. A 12 January updated event records the previous quantity. The row ends January at 1 × $20. | $40.00 | $20.00 |
| Upgrade | $20 on 1 January. An 18 January updated event records the previous price. The row ends January at $90. | $20.00 | $90.00 |
| Cancel | $40 every month. ended_at is 15 January. Status is canceled. | $40.00 | $0.00 |
| New | $30 subscription created on 8 January. Absent from the 1 January book, so it is new MRR. | $0.00 | $30.00 |
The four starting customers are $200.00 of starting MRR. Churned MRR is $40.00. Contraction is $20.00. Expansion is $70.00. Gross retained MRR is $140.00, so GRR is 70%. Retained MRR, which adds expansion back, is $210.00, so NRR is 105%. New MRR is $30.00. Ending MRR of the whole currency, including that new logo, is $240.00. Dividing $240.00 by $200.00 is 120%. That quotient mixes in a customer who was not in the starting book. It is not NRR.
The same function on one extra labeled case at a time:
- A $120 yearly price that stays active. Normalized MRR is $10.00 at both boundaries. NRR is 100%. The yearly amount is not added whole.
- That same $120 yearly price, with
ended_aton 15 January. Churned MRR is $10.00, not $120. NRR is 0%. - A $50 customer who stays, plus a customer whose old subscription ended in December and who starts a $12 subscription on 8 January. Starting MRR is $50.00. Reactivation MRR is $12.00. NRR stays 100%. Ending MRR of the currency is $62.00, and $62.00 divided by $50.00 is not the retention rate.
cancel_at_period_endwith noended_at. Scheduled rows still in the ending book: 1. NRR is 100% on $25.00. The click that schedules the cancellation is not the month the MRR leaves.- The same USD book plus ¥1,500 a month. The USD NRR is still 105%. The yen book is ¥1,500 on its own, with NRR 100%. The yen amount is not added to the dollars.
Starting MRR from subscriptions, items, and prices
Monthly recurring revenue here is each subscription item normalized to one month. A one-time charge is outside it. Cash collected this month is outside it. The Subscription, Subscription Item, and Price objects do not include an MRR field. You compute it.
price.unit_amountis minor units. USD divides by 100. A zero-decimal currency such as JPY divides by 1. The normalizer'sminorUnitFactoris the rule. Do not divide every currency by 100.- Multiply by
quantity. A seat removed from 2 to 1 is contraction if the customer stays. It is not a lost logo. recurring.intervalandinterval_countset the month factor. A year divides by 12 timesinterval_count. A quarter ismonthwithinterval_count3. A week multiplies by 52/12. A day multiplies by 365/12. The MRR API guide is the full interval and coupon write-up. This page calls that normalizer.usage_type: meteredandbilling_scheme: tieredare skipped. A per-unit rate is not a flat fee. Usage belongs in a separate report. Skipped rows incrementskippedItems.- Item percent-off and amount-off coupons apply before subscription coupons.
duration: oncedoes not change MRR. Forever coupons apply. Repeating coupons apply whileendis null or still in the future. An unexpanded discount id does not change the amount, and it incrementsunexpandedDiscounts. The discounts on the subscription at read time are what both boundaries use. This function does not rewind a coupon that was added mid-window.
The default book counts status active after trial_end. A subscription still inside the trial contributes no MRR, so a trial that converts during the month is new MRR, not expansion. past_due and paused stay out unless you opt in. pause_collection does not change status, so those subscriptions stay. unpaid, incomplete, and incomplete_expired are out. cancel_at_period_end stays in until ended_at.
Expansion, contraction, churn, invoices, and refunds
Compare each customer inside one currency at the two boundaries. The window for events is half-open on the right: created at or after periodStart and before periodEnd. A subscription whose ended_at equals periodEnd is churned in this window.
- Present at the start, absent at the end: add their starting MRR to churned MRR.
- Present at both boundaries, ending MRR lower: add the decrease to contraction MRR.
- Present at both boundaries, ending MRR higher: add the increase to expansion MRR.
- Absent at the start, present at the end, with an earlier ended subscription: reactivation MRR. Leave it out of NRR and GRR.
- Absent at the start, present at the end, with no earlier ended subscription: new MRR. Leave it out of NRR and GRR.
Invoices are the wrong source for these lines. amount_paid on a paid invoice is cash in that period. An annual invoice can be the whole year on the day it is paid, which is twelve times the MRR of that price. A proration line adjusts the current period for a mid-cycle change. The run-rate is the subscription item after the change, not the proration. A refund reduces amount_refunded on the charge. It does not change price.unit_amount. This function does not read Invoice, Charge, or Refund objects.
Currencies stay in separate books. Stripe's MRR growth chart can include an FX adjustment when it converts. This function does not convert. A customer with dollars and yen is counted in each book and listed in customersInMultipleCurrencies. Two currencies on one subscription follow the MRR normalizer: the first priced currency is the book, and later items in another currency are skipped.
The Subscription object keeps the latest items. A downgrade inside the month is visible at the start only when an updated event includes previous_attributes.items. Stripe lists events going back up to 30 days. When the window starts before that, eventsLookbackIncomplete is true. ended_at still marks a cancellation. The old quantity does not. If items changed and the previous array has no price, itemChangesUnreconstructed increments and both boundaries use the current items, so contraction can disappear. Store a snapshot when the month has to stay auditable.
List subscriptions and events with auto-pagination
stripe.subscriptions.list takes one status. The snippet requests active, trialing, past_due, paused, unpaid, and canceled. Omitting status returns subscriptions that have not been canceled. A customer who left is missing from that list, so churned MRR looks like zero and NRR looks like 100% plus whatever expanded.
The default page size is 10. The maximum limit is 100. autoPagingToArray follows starting_after until the list ends or the local cap of 100,000 records. That cap is not a Stripe maximum. Expand data.discounts.source.coupon on the subscription list. Stripe allows four expand levels, so an item coupon needs subscriptionItems.list with data.discounts.source.coupon.
events.list uses the subscription event types in one types array. Pass either type or types. The API rejects both. customer.subscription.deleted is sent when the subscription ends. Setting cancel_at_period_end sends customer.subscription.updated first.
Install stripe. Copy lib/tools/stripe-mrr.ts with its MIT notice, and copy lib/guides/calculate-stripe-churn.ts with this file. Pass the secret key only on the server. calculateNetRevenueRetentionFromStripe lists, then calls calculateNetRevenueRetentionFromListedSubscriptions. The listed-subscription function is the same math for objects you already have in tests.
/**
* Net revenue retention (NRR) and gross revenue retention (GRR) from Stripe.
*
* Stripe does not return either field. This file lists the same subscriptions
* and subscription events as `calculateChurnFromStripe`, then keeps the
* starting customers only.
*
* GRR = (starting MRR - churned MRR - contraction MRR) / starting MRR
* NRR = (starting MRR - churned MRR - contraction MRR + expansion MRR) / starting MRR
*
* New MRR and reactivation MRR stay out of both rates. Monthly normalization
* is `normalizeStripeSubscriptionMrr` in `lib/tools/stripe-mrr.ts` (MIT),
* called from `calculateChurnFromListedSubscriptions`.
*
* Run the Stripe calls on the server. `STRIPE_SECRET_KEY` is a secret key.
* The Events API lists events going back up to 30 days.
*/
import Stripe from "stripe"
import {
CHURN_EVENT_TYPES,
CHURN_LIST_STATUSES,
STRIPE_EVENT_RETENTION_SECONDS,
SUBSCRIPTION_LIST_EXPAND,
calculateChurnFromListedSubscriptions,
toChurnEventInput,
toChurnSubscriptionInput,
type ChurnEventInput,
type ChurnReport,
type ChurnSubscriptionInput,
type ChurnWindowOptions,
type CalculateStripeChurnOptions,
} from "./calculate-stripe-churn"
export type { ChurnWindowOptions, CalculateStripeChurnOptions }
/** Same local cap as the churn list. Stripe's list `limit` max is 100. */
const AUTO_PAGE_LIMIT = 100_000
export interface CurrencyRetention {
currency: string
/** Major units, already rounded by the MRR normalizer. */
startingMrr: number
/**
* Ending MRR of the starting customers only.
* starting MRR - churned MRR - contraction MRR + expansion MRR.
* New and reactivation MRR are not in this number.
*/
retainedMrr: number
/** starting MRR - churned MRR - contraction MRR. Expansion is excluded, so this cannot exceed starting MRR. */
grossRetainedMrr: number
/** Ending MRR of every customer in the currency, including new and reactivation. Not the NRR numerator. */
endingMrr: number
churnedMrr: number
contractionMrr: number
expansionMrr: number
newMrr: number
reactivationMrr: number
/** Null when starting MRR is 0. */
grossRevenueRetention: number | null
/** Null when starting MRR is 0. Can be above 1. */
netRevenueRetention: number | null
grossMrrChurnRate: number | null
netMrrChurnRate: number | null
}
export interface RetentionReport {
periodStart: string
periodEnd: string
byCurrency: CurrencyRetention[]
/** True when `periodStart` is strictly older than 30 days before `now`. Item history before that is incomplete. */
eventsLookbackIncomplete: boolean
itemChangesUnreconstructed: number
skippedItems: number
unexpandedDiscounts: number
customersInMultipleCurrencies: number
/** Still in the ending book. `cancel_at_period_end` has not removed their MRR yet. */
scheduledToCancelAtPeriodEnd: number
startedAndEndedInPeriod: number
}
export function ratio(part: number, whole: number): number | null {
if (!(whole > 0)) return null
return part / whole
}
export function grossRevenueRetention(startingMrr: number, churnedMrr: number, contractionMrr: number): number | null {
return ratio(startingMrr - churnedMrr - contractionMrr, startingMrr)
}
export function netRevenueRetention(
startingMrr: number,
churnedMrr: number,
contractionMrr: number,
expansionMrr: number,
): number | null {
return ratio(startingMrr - churnedMrr - contractionMrr + expansionMrr, startingMrr)
}
export function retentionFromChurnReport(report: ChurnReport): RetentionReport {
return {
periodStart: report.periodStart,
periodEnd: report.periodEnd,
byCurrency: report.byCurrency.map((row) => {
const grossRetainedMrr = row.startingMrr - row.churnedMrr - row.contractionMrr
const retainedMrr = grossRetainedMrr + row.expansionMrr
return {
currency: row.currency,
startingMrr: row.startingMrr,
retainedMrr,
grossRetainedMrr,
endingMrr: row.endingMrr,
churnedMrr: row.churnedMrr,
contractionMrr: row.contractionMrr,
expansionMrr: row.expansionMrr,
newMrr: row.newMrr,
reactivationMrr: row.reactivationMrr,
grossRevenueRetention: ratio(grossRetainedMrr, row.startingMrr),
netRevenueRetention: ratio(retainedMrr, row.startingMrr),
grossMrrChurnRate: row.grossMrrChurnRate,
netMrrChurnRate: row.netMrrChurnRate,
}
}),
eventsLookbackIncomplete: report.eventsLookbackIncomplete,
itemChangesUnreconstructed: report.itemChangesUnreconstructed,
skippedItems: report.skippedItems,
unexpandedDiscounts: report.unexpandedDiscounts,
customersInMultipleCurrencies: report.customersInMultipleCurrencies,
scheduledToCancelAtPeriodEnd: report.scheduledToCancelAtPeriodEnd,
startedAndEndedInPeriod: report.startedAndEndedInPeriod,
}
}
export function calculateNetRevenueRetentionFromListedSubscriptions(
subscriptions: readonly ChurnSubscriptionInput[],
events: readonly ChurnEventInput[] = [],
options: ChurnWindowOptions,
): RetentionReport {
return retentionFromChurnReport(calculateChurnFromListedSubscriptions(subscriptions, events, options))
}
/**
* List every status the retention book might count, then list subscription
* events. `subscriptions.list` takes one status. The default list omits
* canceled subscriptions, so a customer who left is invisible without
* `status=canceled`.
*/
export async function calculateNetRevenueRetentionFromStripe(
stripe: Stripe,
options: CalculateStripeChurnOptions,
): Promise<RetentionReport> {
const pageLimit = options.pageLimit ?? AUTO_PAGE_LIMIT
const now = options.now ?? new Date()
const periodStart = Math.floor(options.periodStart.getTime() / 1000)
const nowUnix = Math.floor(now.getTime() / 1000)
const retentionFloor = nowUnix - STRIPE_EVENT_RETENTION_SECONDS
const eventGte = Math.max(periodStart, retentionFloor)
if (periodStart < retentionFloor) {
console.warn(
`[Data Lighthouse] Stripe events are listed going back up to 30 days. NRR window start ${options.periodStart.toISOString()} is older than that, so item changes before the retained events are not reconstructed.`,
)
}
const statusPages = await Promise.all(
CHURN_LIST_STATUSES.map(async (status) => {
const subscriptions = await stripe.subscriptions
.list({
status,
limit: 100,
expand: [...SUBSCRIPTION_LIST_EXPAND],
})
.autoPagingToArray({ limit: pageLimit })
if (subscriptions.length >= pageLimit) {
console.warn(`[Data Lighthouse] Stripe auto-pagination stopped at ${pageLimit} ${status} subscriptions.`)
}
return subscriptions
}),
)
const seen = new Set<string>()
const listed: ChurnSubscriptionInput[] = []
for (const subscription of statusPages.flat()) {
if (seen.has(subscription.id)) continue
seen.add(subscription.id)
listed.push(await toChurnSubscriptionInput(stripe, subscription, pageLimit))
}
const events = await stripe.events
.list({
types: [...CHURN_EVENT_TYPES],
created: { gte: eventGte, lt: nowUnix + 1 },
limit: 100,
})
.autoPagingToArray({ limit: pageLimit })
if (events.length >= pageLimit) {
console.warn(`[Data Lighthouse] Stripe auto-pagination stopped at ${pageLimit} subscription events.`)
}
const mappedEvents: ChurnEventInput[] = []
for (const event of events) {
const mapped = toChurnEventInput(event)
if (mapped) mappedEvents.push(mapped)
}
return calculateNetRevenueRetentionFromListedSubscriptions(listed, mappedEvents, { ...options, now })
}
import { NextResponse } from "next/server"
import { createStripeClient } from "@/lib/guides/calculate-stripe-mrr"
import { calculateNetRevenueRetentionFromStripe } from "@/lib/guides/calculate-stripe-nrr"
export async function GET() {
const key = process.env.STRIPE_SECRET_KEY
if (!key) {
return NextResponse.json({ error: "Missing STRIPE_SECRET_KEY" }, { status: 500 })
}
const periodEnd = new Date()
const periodStart = new Date(periodEnd.getTime() - 30 * 24 * 60 * 60 * 1000)
const report = await calculateNetRevenueRetentionFromStripe(createStripeClient(key), {
periodStart,
periodEnd,
})
return NextResponse.json(report)
}
"use server"
import { createStripeClient } from "@/lib/guides/calculate-stripe-mrr"
import { calculateNetRevenueRetentionFromStripe } from "@/lib/guides/calculate-stripe-nrr"
export async function nrrForTrailing30Days() {
const key = process.env.STRIPE_SECRET_KEY
if (!key) throw new Error("Missing STRIPE_SECRET_KEY")
const periodEnd = new Date()
const periodStart = new Date(periodEnd.getTime() - 30 * 24 * 60 * 60 * 1000)
return calculateNetRevenueRetentionFromStripe(createStripeClient(key), { periodStart, periodEnd })
}
The route uses the trailing 30 days, which fits inside the Events API retention when you run it now. A calendar month that started more than 30 days ago still has ended_at for cancellations. Treat eventsLookbackIncomplete as a warning on item changes, and keep a snapshot if that month has to stay exact.
SQL over synced snapshot tables
The sync guide's stripe_subscriptionsrow stores an id, a status, and a customer id. That current row cannot compute NRR. It has no memory of the price on the first of the month. The queries below read tables you add when you snapshot the normalized book. The names are the ones this page uses. They are not a claim about Stripe Sigma's column list. mrr is already one month, in major units, for one currency.
stripe_mrr_snapshots has as_of, customer_id, currency, and mrr. The period query left joins the ending snapshot onto the starting customers. A missing ending row is churned MRR. An inner join would drop that customer from both the numerator and the denominator and make retention look healthier than the starting book was.
with bounds as (
select
timestamptz '2026-01-01 00:00:00+00' as period_start,
timestamptz '2026-02-01 00:00:00+00' as period_end
),
start_book as (
select customer_id, currency, sum(mrr) as mrr
from stripe_mrr_snapshots
where as_of = (select period_start from bounds)
and mrr > 0
group by customer_id, currency
),
end_book as (
select customer_id, currency, sum(mrr) as mrr
from stripe_mrr_snapshots
where as_of = (select period_end from bounds)
and mrr > 0
group by customer_id, currency
),
joined as (
select
s.currency,
s.customer_id,
s.mrr as starting_mrr,
coalesce(e.mrr, 0) as ending_mrr
from start_book s
left join end_book e
on e.customer_id = s.customer_id
and e.currency = s.currency
)
select
currency,
sum(starting_mrr) as starting_mrr,
sum(case when ending_mrr = 0 then starting_mrr else 0 end) as churned_mrr,
sum(case when ending_mrr > 0 and ending_mrr < starting_mrr then starting_mrr - ending_mrr else 0 end) as contraction_mrr,
sum(case when ending_mrr > starting_mrr then ending_mrr - starting_mrr else 0 end) as expansion_mrr,
sum(least(ending_mrr, starting_mrr)) / nullif(sum(starting_mrr), 0) as gross_revenue_retention,
sum(ending_mrr) / nullif(sum(starting_mrr), 0) as net_revenue_retention
from joined
group by currency;
Cohort NRR repeats the idea for the customers whose first positive snapshot falls in one month. The left join keeps a later month's missing row at zero, so the cohort's starting MRR stays the denominator.
with first_month as (
select customer_id, currency, min(as_of) as cohort_month
from stripe_mrr_snapshots
where mrr > 0
group by customer_id, currency
),
cohort_start as (
select s.customer_id, s.currency, f.cohort_month, s.mrr as start_mrr
from stripe_mrr_snapshots s
join first_month f
on f.customer_id = s.customer_id
and f.currency = s.currency
and s.as_of = f.cohort_month
),
months as (
select distinct as_of from stripe_mrr_snapshots
)
select
c.currency,
c.cohort_month,
m.as_of,
sum(c.start_mrr) as cohort_starting_mrr,
sum(coalesce(s.mrr, 0)) as cohort_mrr,
sum(least(coalesce(s.mrr, 0), c.start_mrr)) / nullif(sum(c.start_mrr), 0) as cohort_gross_revenue_retention,
sum(coalesce(s.mrr, 0)) / nullif(sum(c.start_mrr), 0) as cohort_net_revenue_retention
from cohort_start c
join months m on m.as_of >= c.cohort_month
left join stripe_mrr_snapshots s
on s.customer_id = c.customer_id
and s.currency = c.currency
and s.as_of = m.as_of
group by c.currency, c.cohort_month, m.as_of
order by c.currency, c.cohort_month, m.as_of;
If you would rather store items than a finished MRR number, normalize with the same factors as the TypeScript function. Divide unit_amount by the minor-unit factor before this statement. The statement does not apply coupons, and it does not see a quantity that changed after you stored the row.
select
si.subscription_id,
si.currency,
case p.recurring_interval
when 'year' then (si.quantity * si.unit_amount_major) / (12.0 * p.recurring_interval_count)
when 'month' then (si.quantity * si.unit_amount_major) / p.recurring_interval_count
when 'week' then (si.quantity * si.unit_amount_major) * (52.0 / 12.0) / p.recurring_interval_count
when 'day' then (si.quantity * si.unit_amount_major) * (365.0 / 12.0) / p.recurring_interval_count
end as monthly_amount
from stripe_subscription_items si
join stripe_prices p on p.id = si.price_id
where p.recurring_usage_type = 'licensed'
and p.billing_scheme = 'per_unit';
Paid invoices are still cash. Do not sum them into starting_mrr. How those snapshots get into Postgres, by webhook plus a reconciliation list, is how to sync Stripe data for a SaaS metrics dashboard.
Cohort NRR and period NRR
Period NRR, which is what the TypeScript function returns, takes every qualifying customer at periodStart and measures those same customers at periodEnd. One window produces one rate per currency. It mixes customers who arrived years ago with customers who arrived last month.
Cohort NRR groups customers by the month they first had positive MRR, then divides that group's later MRR by the group's MRR in the starting month. A cohort can be above 100% in month 12 while the latest calendar month is below 100%, because the customer sets differ. Cohort analysis is the general idea of holding the acquisition group fixed. This section is that idea applied to normalized MRR.
Stripe's Billing analytics page, checked 19 November 2026, assigns cohorts by when a subscriber first generated positive MRR. It says revenue retention includes expansion and can exceed 100%. Its worked illustration starts 100 subscribers on 10 USD plans, so starting MRR is 1,000 USD. By the end of the first month, 10 subscribers have churned and 5 have upgraded to 25 USD plans. Stripe labels the net effect as 125 USD of expansion minus 100 USD of churn, an increase of 25 USD, and 102.5% revenue retention. Those figures are Stripe's, from that page. They are not this repository's example and they are not a benchmark.
Expansion on this page is the increase, not the new price. Five customers moving from 10 USD to 25 USD are 75 USD of expansion. Ten customers leaving at 10 USD are 100 USD of churned MRR. Under the formula in the first section, that story is (1,000 − 100 + 75) / 1,000 = 97.5%. Stripe's paragraph uses 125 USD, which is five times the new 25 USD price, and reports 102.5%. Reconcile the Dashboard cohort chart to Stripe's write-up. Reconcile this function to the increase.
The same Stripe page also shows subscriber retention under a constant 10% subscriber churn assumption: 90%, 81%, 73%, 66%, and 59% across the next five months. That list is logo retention in Stripe's illustration. It is not NRR, and it is not a target this page is recommending.
You cannot rebuild a 12-month cohort from events.list. The Events API goes back up to 30 days. Stripe's prebuilt "MRR per subscriber per month" and "Subscription metrics per month" reports are the Dashboard exports for a longer book. Date columns in those reports use UTC. Billing analytics charts use the account time zone, so a month boundary can move. Pass UTC instants into this function and use the same instants in the SQL.
Pitfalls that move the rate
- Using today's active list as the starting book. Canceled customers are missing, so churned MRR is zero and NRR is flattered.
- Stopping after the first page. The default page size is 10. Canceled subscriptions are on their own status list.
- Adding new MRR or reactivation MRR to the numerator. That is closer to the MRR growth identity, which also adds those lines and can add an FX adjustment.
- Calling a downgrade a lost logo, or calling a second subscription for an existing customer new MRR. The dollars are contraction or expansion.
- Counting
cancel_at_period_endon the day the customer clicks.ended_atis the exit. - Treating a trial that never converts as churn.
trial_endin the future is outside the default book. - Dividing a yearly cancellation by the full yearly price. $120 a year is $10 of MRR.
- Summing paid invoices, prorations, or refunds into MRR. Those are cash. The price on the item is the run-rate.
- Adding USD and JPY, or dividing a zero-decimal currency by 100. One book per currency.
- Inner-joining the ending snapshot. Churned customers vanish from the denominator.
- Trusting item history on the current Subscription object. Previous quantities live on the updated event, and events older than 30 days are gone.
- Ignoring
itemChangesUnreconstructed. Both boundaries used the current price, so a downgrade is invisible and NRR is too high. - Comparing a cohort chart with a one-month period rate, or comparing a rate that includes
past_duewith one that does not. - Reading GRR above 100%. If the figure exceeds 100%, expansion was left in and the rate is not GRR.
What good looks like, without a borrowed target
NRR above 100% means the starting customers, as a group, were worth more in normalized MRR at the end of the window than at the start. Expansion covered churn and contraction. NRR of 100% means those movements offset. NRR below 100% means the starting book shrank. GRR of 100% means that book had no churn and no contraction. GRR below 100% means some of the starting MRR was lost even before you give credit for upgrades.
Those sentences describe the sign of the rate. They are not a score for every product. A single-seat subscription often has nowhere for expansion to come from, so NRR above 100% is not available unless the price itself went up. A seat-based product can print NRR above 100% in a month when a few accounts add seats and several small logos cancel. The rate is then true and still hides the logo loss. Read GRR, or the churned-customer count, next to NRR.
Compare a number only with the same formula, the same window, the same currency, and the same decision about past_due, trials, and scheduled cancellations. A cohort rate and a period rate are different customer sets. This page does not publish a numeric target, and it does not treat another company's reported NRR as one.
From the formula to a dashboard
Calculating the rate is the top of the funnel. Keeping the two snapshots, or the event log that reconstructs them, is the next decision. How to sync Stripe data for a SaaS metrics dashboard covers a paginated list, webhooks with an event id, and a reconciliation pass. The Events API alone cannot hold a year of item history. Whether to build that pipeline, pay a hosted metrics product, or start from a template is build vs buy a SaaS metrics dashboard.
The SaaS metrics dashboard template is $59 once. You host the Next.js app. The Next.js Stripe analytics dashboard normalizes active subscriptions to MRR and shows ARR as that MRR times 12. The overview does not compute NRR, GRR, or LTV. How to calculate customer lifetime value from Stripe divides ARPU by the customer churn fraction from this starting book. Retention and lifetime value stay separate numbers. The live demo renders the overview with sample data and does not call Stripe.
The SaaS metrics calculator runs the monthly normalization in the browser from plans you type. The Stripe MRR CSV calculator does the same for one subscriptions export and does not upload the file. Two exports, one at each boundary, are the CSV path to the formulas above. Neither calculator returns NRR.
Sources
Stripe's API reference for the list calls, and the Billing analytics page for the cohort illustration quoted above. That page was checked 19 November 2026. The hypothetical January book was produced by the function in this repository.
Net revenue retention questions
Short answers on NRR, GRR, expansion, and cohorts.
How do you calculate net revenue retention (NRR) from Stripe?
Stripe does not return an NRR field. List subscriptions, including canceled ones, and subscription events. Normalize each qualifying subscription to one month. NRR is the ending MRR of the customers who had MRR at the start, divided by that starting MRR. Ending MRR here means starting MRR minus churned MRR minus contraction MRR plus expansion MRR. New customers and reactivations stay outside the rate.
What is gross revenue retention (GRR) from Stripe?
GRR uses the same starting customers and the same churned and contraction MRR as NRR, and it leaves expansion out. The formula is (starting MRR − churned MRR − contraction MRR) / starting MRR. Because expansion is excluded, GRR cannot rise above 100% when ending MRR is zero or positive. NRR equals GRR plus expansion MRR divided by starting MRR. Gross MRR churn is 1 minus GRR when both use this starting book.
What is the difference between expansion MRR and new MRR?
Expansion is an increase from a customer who was already in the starting book: a higher price, more quantity, or a second subscription for that customer. New MRR is a customer who was absent at the start. Reactivation MRR is a customer who was absent at the start and had an earlier subscription that had already ended. Putting new or reactivation MRR into the numerator measures something closer to MRR growth than retention.
Do refunds, prorations, trials, and annual prices change Stripe NRR?
A refund changes cash on a charge. It does not change the subscription price, so this calculation does not read Refund objects. A proration is an invoice adjustment for part of a period. The run-rate is the subscription item after the change, not the proration line. A subscription still inside trial_end is outside the default book, so a trial that converts during the month is new MRR, not expansion. A yearly price is divided by 12 before it enters MRR. Canceling a $120 yearly plan removes $10 of MRR. cancel_at_period_end stays in the book until ended_at.
Why is cohort NRR different from NRR for a single month?
Period NRR takes everyone with qualifying MRR at the start of that window. Cohort NRR takes the customers who first had positive MRR in one acquisition month and follows only those customers. Stripe Billing analytics assigns cohorts by the month a subscriber first generated positive MRR, and it says that cohort's revenue retention can exceed 100% because upgrades are included. A strong old cohort and a weak latest month can both be true. The Events API goes back up to 30 days, so a 12-month cohort needs stored snapshots or a Dashboard export.
What does good net revenue retention look like?
NRR above 100% means the starting customers, as a group, were worth more at the end of the window than at the start. Expansion covered churn and contraction. NRR of 100% means those losses and expansion offset. NRR below 100% means the starting book shrank. GRR at 100% means the starting book had no churn and no contraction. None of those descriptions is a target for every company. A product with no seats to add often cannot print NRR above 100% even when logos stay. A rate above 100% can still hide lost logos if a few upgrades are large. Compare a rate only with the same formula, window, currency, and status rules.
Can I calculate NRR from Stripe without hosting this code?
Export the subscriptions CSV at the start of the period and again at the end. The Stripe MRR CSV calculator at https://datalighthouse.dev/tools/stripe-mrr-csv-calculator normalizes one file in the browser and does not upload it. It returns MRR per currency, not NRR. Compare the two files by customer id with the formulas on this page. Data Lighthouse is a self-hosted Next.js template. The overview does not compute NRR or GRR. The license is $59 once. The buyer page is https://datalighthouse.dev/saas-metrics-dashboard-template and the sample dashboard is https://datalighthouse.dev/demo. The demo uses sample data and does not call Stripe.