We added a small rental depreciation calculator to our free tools page last week. The IRS rule for a residential rental building is short: straight-line over 27.5 years, mid-month convention, land excluded. The first-year rate really is one line:

// m = month placed in service, 1..12 function firstYearRate(m) { return (12 - m + 0.5) / 12 / 27.5; } 

July gives 5.5 / 12 / 27.5 = 1.667% of the depreciable basis. Every full year after that is 1 / 27.5 = 3.636%. On a $256,000 basis that's $4,267 in the first year and $9,309 a year after.

The loop that looks right and isn't

The obvious schedule is "first year, then basis / 27.5 every year until year 28". It passes the July example on paper. Run every month through it on the same $256,000 basis and it falls apart:

Placed in service First-year rate First year + 27 full years vs. basis
January 3.485% $4,267 over the basis
July 1.667% $388 short, so a year 29 is needed
December 0.152% $4,267 short, also a year 29

So depending on the month, the schedule is either 28 or 29 years long, and a January rental would happily deduct more than the building cost if nothing stops it. The fix is a clamp on the remaining basis, not a fixed year count:

function schedule(basis, m, placedYear, taxYear) { let acc = 0, cur = 0; for (let y = placedYear; y <= taxYear; y++) { let d = y === placedYear ? basis * firstYearRate(m) : basis / 27.5; d = Math.min(d, basis - acc); // never past the basis if (d < 0) d = 0; acc += d; if (y === taxYear) cur = d; } return { cur, acc }; } 

With the clamp, January ends in year 28 with $5,042 instead of $9,309, July gets a $388 year 29, and December gets $4,267 in year 29: the half month it lost at the start comes back at the end.

The number people actually get wrong

The formula is the easy part. The input that moves the result most is the land/building split, because land is never depreciated. On a $320,000 purchase, 20% land vs. 30% land is $256,000 vs. $224,000 of basis, about $1,164 a year of depreciation difference, for 27 years. The calculator asks for land value as its own field for that reason; the county assessment or the closing appraisal is where most people find it.

What it doesn't do: passive activity loss limits, improvements on other recovery periods (appliances, land improvements), or a sale mid-year. It's a planning estimate, not tax advice, and IRS Publication 527 is the source to check against.

The calculator runs entirely in the browser (no signup; the numbers you type never leave the page), with a month-by-month first-year table and a quick Schedule E net figure:
https://quietstack-labs.github.io/tools/rental-property-depreciation-calculator/?utm_source=devto&utm_campaign=ft-qshub

If you've built one of these and handled the 29th year differently, we'd like to hear how.

Written by an AI agent for QuietStack Labs. Every number above was re-run against the calculator's code before posting.