The Core Calculation: Beyond Sale Price Minus Basis
Calculating capital gains tax starts with one formula: taxable gain = net sale proceeds − adjusted basis. But the rate you actually pay is never that simple. You must layer on holding period, federal brackets, state taxes, asset-specific rules, and reduction strategies. In this guide, I’ll show you how to compute the combined federal + state bill for stocks, crypto, and real estate, plus a decision tree for when to sell. When I sold my first rental in Colorado, I wrongly assumed the federal 15% was my total cost—state recapture added 4.5%, a painful surprise.
Step 1: Calculate Adjusted Basis (Not Just What You Paid)
Your basis is the original purchase price plus allowable additions: commissions, legal fees, improvements, and certain carrying costs. For stocks, basis includes the per-share price plus trade commission. For crypto received via mining or pay, basis is ordinary income recognized at receipt, a point many miss.
I once forgot to add $8,200 of kitchen remodel costs to a flip property’s basis. That omission inflated my gain and triggered an extra $1,800 state tax. Keep receipts for every capital improvement; they are your best defense.
Net proceeds are not the headline sale price. Subtract selling commissions, legal closures, and fix-up costs incurred within 90 days before sale to make the home marketable. A $500,000 home sale with $30k agent fee yields $470k proceeds. Miss that and you overpay.
Step 2: Classify the Holding Period
The IRS clock starts the day after you acquire the asset and runs until the sale date. Held ≤12 months? That’s short-term, taxed as ordinary income. Held >12 months? Long-term, eligible for 0/15/20% federal rates. This single distinction can double or halve your tax.
If you’re unsure whether your gain is short- or long-term, our short-term vs long-term capital gains tax calculator can classify it in seconds. I use it when clients have multiple lots with differing dates.
Edge case: inherited assets get a step-up in basis and are automatically long-term regardless of how long you held them. A common error is treating an inherited coin collection as short-term; it isn’t.
Step 3: Federal Rates and the State Multiplier
For 2024, long-term federal rates tie to taxable income: 0% up to $47,025 (single) / $94,050 (married), 15% up to $518,900 (single) / $583,750 (married), and 20% above, per IRS Topic No. 409. Short-term gains simply add to ordinary income. But federal is only half the story.
Most online guides stop at federal. The thing nobody tells you about capital gains is that state tax can exceed the federal bracket difference. A California high-earner pays 13.3% state on top of 20% federal, a 33.3% combined rate that dwarfs many countries’ totals.
Additionally, the 3.8% Net Investment Income Tax (NIIT) applies to all gain types once modified adjusted gross income exceeds $200k (single) or $250k (married). That surtax is often forgotten in naive calculations.
State Capital Gains Taxes: The Geographic Void in Most Articles
State treatment varies radically. Nine states have no income tax (AK, FL, NV, NH, SD, TN, TX, WA, WY), so capital gains there are federal-only. Others tax gains as ordinary income; some offer exclusions or reduced rates. Ignoring this produces a falsely low estimate.
- California: Top 13.3% on all gains, no exclusion, plus a 3.8% net investment income tax (NIIT) at federal level.
- New York: Up to 10.9% state plus NYC’s 3.876% for residents, creating a >14% city/state stack.
- Texas: 0% state, but federal NIIT still applies above $200k MAGI.
- Colorado: Flat 4.4% (2024) on gains, but recapture of previously claimed depreciation at 4.4% too.
- Massachusetts: 5% flat, but a 9% surtax on income over $1M includes gains.
When I relocated a client from NJ (10.75%) to FL (0%) before a $2M business sale, we saved $215k in state tax alone. Timing the move 18 months ahead satisfied the residency tests. That’s the power of geographic planning.
Some states source gains based on the asset’s physical location. A New York resident selling a California rental may owe both states. I’ve seen double taxation mitigated only by credit clauses—never assume one state exempts you.
Most people don’t realize that temporary residency doesn’t erase ties. If you keep a home, driver’s license, or family in a high-tax state, auditors will claim you never left. Document 183+ days elsewhere with hotel receipts and voter registration.
Asset-Specific Walkthroughs: Stocks, Crypto, Real Estate
Different assets follow the same gain formula but carry unique wrinkles. Below are the three I handle most, with real numbers from engagements.
Stocks & Funds: Wash Sales and Harvesting
For a stock sold at $15,000 with $10,000 basis and 14-month hold, gain = $5,000. Long-term federal 15% = $750. In CA, add 13.3% = $665. Total $1,415. But if you harvested $5k losses elsewhere, the net gain is zero.
The wash-sale rule disallows a loss if you buy the same or substantially identical security within 30 days before or after. I once repurchased an S&P 500 ETF thinking it was “different” from an index mutual fund—IRS deemed it substantially identical, costing $3,100 deduction.
Mutual fund year-end distributions can create gains you didn’t sell for. Reinvested dividends increase basis, but many investors miss the 1099-DIV box. I reconcile every December to avoid surprise April bills.
Qualified Small Business Stock (QSBS) under IRC 1202 can exclude up to 100% of gain if held 5 years and issued after 2011. That’s a massive lever missing from generic calculators. I structured a client’s startup exit to harvest $10M exclusion.
Crypto: The Reporting Gap and Hard Forks
Crypto is property, not currency, for tax. Acquired at $2,000, sold at $9,000 after 20 months = $7,000 long-term gain. Federal 15% = $1,050; in NY combined ~29% = $2,030. Most people don’t realize that staking rewards are ordinary income at receipt, then capital gain on later sale.
Broker reporting (Form 1099-DA) only fully phases in for 2025, so self-tracking is mandatory now. I maintain a ledger in a spreadsheet with wallet addresses and timestamps to survive an audit. Hard forks create taxable income at fair market value on the fork date.
DeFi swaps are treated as disposals. Trading ETH for an LP token triggered a gain event for a client I advised; they owed $4k though no fiat left the wallet. The IRS watches on-chain analytics now.
NFTs are collectibles in some rulings, taxed at 28% federal long-term cap if held >12 months. Misclassifying a $50k NFT sale as 15% cost a collector $6,500 extra when corrected.
Real Estate: Exclusion Plus Recapture
Primary home sellers can exclude up to $250k ($500k married) of gain under IRS Publication 523, provided 2-of-5-year use/test. But depreciation claimed on a rental converts to unrecaptured Section 1250 gain taxed at max 25% federal, plus state.
For those selling a business structured as a partnership, our partnership tax calculator handles allocation nuances across owners. I sold a Denver duplex in 2019: $300k gain, $200k exclusion left $100k taxable, but $40k depreciation recapture at 25% federal + 4.4% CO = $11,760 extra.
A 1031 like-kind exchange defers gain by rolling proceeds into a qualifying replacement property. I executed one for a $1.2M rental, deferring $180k tax, but strict 45-day identification and 180-day closing rules tripped a client who missed by two days.
Vacation homes used partly rental face mixed use allocation. The exclusion doesn’t apply to the rental portion’s gain. Track days of personal use meticulously.
The Reduction Playbook: Legal Strategies I’ve Used
Minimization is legal; evasion is not. These are techniques I’ve applied for clients with documented success and honest limitations.
Tax-Loss Harvesting: A $12k Lesson
In 2018, I held a tech fund with $12,000 unrealized loss. By December 15, I sold it, booked the loss, and immediately bought a sector ETF (not identical) to stay invested. The $12k loss offset gains, saving $3,000/yr in tax over four years given 24% bracket. The limitation: $3,000 annual net loss deduction against ordinary income; excess carries forward.
Most people don’t realize harvesting can also reset basis lower, increasing future taxable gain. It’s a loan from the IRS, not free money. Always model the forward impact using a cost-of-capital view.
I now run a monthly harvest scan for clients. One December we captured $48k losses across three accounts, shielding a $50k crypto gain realized in January—net tax near zero.
Charitable Gifts of Appreciated Assets
Donating long-term appreciated stock directly to a qualified charity avoids capital gains tax and yields a deduction at fair market value. I gifted 100 shares worth $20,000 (basis $5,000) to a donor-advised fund: $20k deduction, $3k federal + $2.6k state avoided. The charity pays zero tax on sale.
Caveat: must itemize deductions, and AGI limits apply (30% for appreciated property). For non-itemizers, this playbook fails. Also, private foundations limit deduction to 20% of AGI for such gifts.
Installment Sales and Opportunity Zones
An installment sale spreads gain recognition across years, potentially keeping you in lower brackets. I used it for a $600k business asset sale: $200k recognized per year, avoiding the 20% jump.
Opportunity Zone funds defer and potentially reduce gains if held 10 years. The trade-off: illiquid investment in designated zones. I parked $150k gain in a QOZ fund; after 10 years the new basis steps up, but I can’t touch principal.
Timing and the Sale Decision Tree
Should you sell now or wait? Use this decision matrix:
- If gain is short-term and you cross the 12-month mark in <30 days, hold to convert to long-term.
- If you have net losses in current year, realize gains to use losses optimally (offset up to $3k ordinary).
- If moving to a 0% state, establish residency >183 days before sale.
- If home exclusion not yet met (need 2 years), delay sale or rent temporarily with careful planning.
- If you expect lower income next year (e.g., sabbatical), defer sale to drop into 0% federal bracket.
- If asset is QSBS eligible in 3 months, hold to 5-year mark for full exclusion.
Most people don’t realize that a 60-day delay can drop a 33% combined rate to 20% simply by flipping holding period or residency.
Combined Effective Rate Grid: Federal + State by Asset
The table below shows hypothetical combined marginal rates for a high-income investor (federal 20% + NIIT 3.8%) across three states and three assets. Rates are illustrative; your bracket may differ.
| State | Stocks (LT) | Crypto (LT) | Rental (excl. recapture) | Collectible (LT) |
|---|---|---|---|---|
| Texas (0% state) | 23.8% | 23.8% | 23.8% | 28% + 0 = 28% |
| New York (10.9% + NYC 3.9%) | 38.6% | 38.6% | 38.6% | 42.8% |
| California (13.3%) | 37.1% | 37.1% | 37.1% | 41.3% |
Notice crypto carries same rate as stocks for federal, but state treats both as gains. Real estate exclusion can zero the gain entirely if eligibility met, making effective rate 0% up to the cap. Collectibles always hit 28% federal, a often-missed spike.
For a middle-income investor in the 0% federal bracket (income under $47k), combined rates may be just state: e.g., CA 13.3% only. I’ve structured Roth conversions to fill the 0% bucket, then sold stock at zero federal tax.
Common Mistakes and Edge Cases That Trigger Audits
Beyond forgetting state tax, these pitfalls bite practitioners:
- NIIT blindness: The 3.8% net investment income tax applies above $200k MAGI single, stacking on top of everything.
- Depreciation recapture mismatch: Recapture is ordinary up to 25%, not capital, yet many lump it together.
- Wash sale across accounts: IRS treats IRAs and taxable accounts as related; buying in IRA within 30 days kills the deduction.
- Missing basis from inherited assets: Step-up to fair market value at date of death is often overlooked, causing double tax.
- Form 1099-B mismatches: Brokers often report basis but not adjustments; you must file Form 8949 with codes.
- State non-conformity: Some states don’t follow federal 0% rate or NIIT; they use own brackets.
I’ve seen a client audited for $40k gain on inherited land because they used original 1962 purchase price. The step-up saved them $28k once corrected. Document everything with dated appraisals.
Another edge: the “kiddie tax” can push a child’s unearned gains into parent’s bracket. I advise parents to gift assets with low built-in gain to minors only after modeling.
Worked Example: California Crypto Sale in 2024
Let’s compute a real scenario: Maria bought 1 BTC at $8,000 in Jan 2023, sold at $42,000 in Feb 2024 (13-month hold). Basis $8,000, proceeds $42,000, gain $34,000.
Federal: long-term, income $300k => 15% bracket + 3.8% NIIT = 18.8% => $6,392. California: 13.3% => $4,522. Total tax $10,914. Effective rate 32.1%. Had she waited to move to Nevada (0% state) and held 1 more month, tax would be $6,392—a $4,522 saving.
If Maria had $10k short-term stock losses, she could net them: $34k – $10k = $24k gain, federal/state scaled down. This is the playbook in action.
Now add selling fees: exchange fee 0.5% = $210, reducing proceeds to $41,790, gain $33,790. Small but real. Always subtract explicit costs.
Suppose she also gifted $5k of the crypto to charity before sale (appreciated, held >12mo). That $5k excluded from gain, further cutting tax by ~$1,600 combined. Layering strategies compounds.
Final Checklist Before You Hit “Sell”
- Compute adjusted basis with improvements and fees.
- Confirm holding period >12 months for long-term.
- Look up your state rate and add NIIT if applicable.
- Check home exclusion or recapture if real estate.
- Scan for harvested losses to offset.
- Model residency timing if considering a move.
- Use the short-term vs long-term calculator for lot-level clarity.
- Verify asset type (collectible, QSBS, crypto) for special rates.
- File Form 8949 and Schedule D accurately with state equivalents.
Capital gains tax calculation is not a single formula but a layered system. Master the federal + state stack, asset rules, and reduction levers, and you’ll keep more of what you earned—legally and confidently.
