Home › Templates › Capital gains tax spreadsheet

Capital Gains Tax Spreadsheet

A free capital gains tax spreadsheet for Excel and Google Sheets (US federal). Log each sale once. It sorts every row into short-term or long-term, picks the Form 8949 box, nets gains and losses line by line like Schedule D, applies the $3,000 loss limit, splits long-term gains into the 2026 0%, 15% and 20% layers, adds the 3.8% net investment income tax and works out next year's loss carryover.

Download Excel template (.xlsx) 114 KB · no macros · Excel 2016+ and Google Sheets · tax years 2026 and 2025 · v1.0, 7 Nov 2026

Use it in Google Sheets: choose File → Import → Upload in Sheets and pick the .xlsx, or upload it to Google Drive and open it with Google Sheets. Every function used (SUMIFS, COUNTIF, EDATE, INDEX, MATCH, MID, MIN, MAX) exists in both.

Preview: the Example log and Example summary tabs. The investor, assets, dates, amounts and income are fictional.
$2,800net short-term gain (Schedule D line 7)
$15,210net long-term gain (line 15)
$16,710 at 15%long-term gains + qualified dividends
$3,467.68estimated federal tax incl. $289.18 NIIT
Asset (fictional)AcquiredSoldProceedsBasisAdj.TermGain/lossBox
Example Fund A (ETF)14 Mar 202310 Feb 2026$18,400$12,000—Long$6,400D
Example Stock B, lot 12 Jun 202520 Jan 2026$9,100$6,500—Short$2,600A
Example Stock C, lot 17 Apr 20253 Mar 2026$3,800$5,000—Short−$1,200A
Example Stock C, lot 2 (wash sale)15 Sep 202510 Mar 2026$2,100$2,700$600Short$0A
Example Stock D, lot 1 (exactly 1 year)15 May 202515 May 2026$7,500$5,200—Short$2,300A
Example Stock D, lot 215 May 202518 May 2026$7,560$5,200—Long$2,360D
Example Bond Fund E (bought 2010)2 Aug 201012 Jun 2026$10,200$11,900—Long−$1,700E
Inherited Stock FInherited1 Jul 2026$15,000$14,200—Long$800D
Example Coin G20 Feb 20245 Aug 2026$8,800$4,100—Long$4,700K
Example Coin H12 Jan 202630 Apr 2026$3,000$3,900—Short−$900G
Example Stock B, lot 21 Nov 202314 Sep 2026$12,500$9,000—Long$3,500D

What's inside the spreadsheet

TabWhat you typeWhat it calculates
Start hereNothingSteps, the rules built in, colour key, limits, disclaimer
Tax summaryTax year (2026 or 2025), filing status, other taxable income, qualified dividends, capital gain distributions, last year's carryovers, your marginal rate, MAGI, other investment incomeTotals for each Form 8949 box; gains and losses by term; Schedule D lines 1b to 21; the Qualified Dividends and Capital Gain Tax Worksheet, lines 1 to 21; NIIT; an estimate of the tax; carryover to next year; a chart of the tax by layer
Sales log500 rows: description, quantity, date acquired, date sold, proceeds, cost basis, adjustment (wash sale), code, 1099 reporting type, digital asset yes/no, term overrideDays held, short or long term, gain or loss (column h), Form 8949 box, a row check that turns red on bad rows
RatesNothing (edit only if the IRS changes a figure)2026 and 2025 thresholds by filing status: 0% and 15% limits, NIIT threshold, loss limit, with the source of each
Example log, Example summaryAlready filled with fictional salesThe same formulas, so you can see a full result first

How to use it

  1. On Sales log, add one row per sale. Copy the description, dates, proceeds and cost basis from your Form 1099-B or 1099-DA, or from your own records for sales with no form.
  2. Pick the reporting type: Basis reported to IRS, Basis not reported to IRS or No 1099-B or 1099-DA. Mark crypto and other digital assets Yes. The sheet uses both to choose the Form 8949 box.
  3. For a wash sale, type the disallowed loss as a positive number in the adjustment column and W in the code column. That is how the Form 8949 instructions say to report it.
  4. For inherited property, leave the acquired date blank and set Term override to Long-term. Publication 550 says inherited property is long-term "regardless of how long you held the property".
  5. On Tax summary, choose the tax year and filing status, then fill the yellow cells. Check that Status says OK and Rows to fix is 0.
  6. Read the Form 8949 box totals and the Schedule D lines, then the estimate. Lost track of a lot's basis? Work it out first in the cost basis spreadsheet.

The rules the formulas follow

Short-term or long-term

IRS Topic 409: "if you hold the asset for more than one year before you dispose of it, your capital gain or loss is long-term. If you hold it one year or less, your capital gain or loss is short-term." You "count from the day after the day you acquired the asset up to and including the day you disposed of the asset" (IRS Topic 409). Publication 550 gives an example: bought on 31 January 2024, sold on 29 January 2025 is short-term; sold on 6 February 2025 is long-term. The sheet tests D5>EDATE(C5,12): the sale date must be after the one-year anniversary. In the example, Stock D lot 1 bought on 15 May 2025 and sold on 15 May 2026 is short-term; lot 2, sold on 18 May 2026, is long-term.

Gain or loss and the Form 8949 box

Column (h) is proceeds minus basis, then "take into account any adjustments in column (g)" (Instructions for Form 8949, 2025). The 2025 instructions added boxes G to L for digital assets reported on the new Form 1099-DA:

Your Form 1099-B / 1099-DAShort-termShort-term digital assetLong-termLong-term digital assetSchedule D line
Shows basis reported to the IRSAGDJ1b / 8b
Basis not reported to the IRSBHEK2 / 9
No form receivedCIFL3 / 10

Exception 1 in the instructions lets you skip Form 8949 for box A, D, G or J sales with no adjustments and put the totals on Schedule D line 1a or 8a. The sheet puts them on 1b and 8b. The totals are the same.

Netting and the $3,000 loss limit

Short-term rows and any short-term carryover give Schedule D line 7. Long-term rows, capital gain distributions and any long-term carryover give line 15. Line 16 combines them (Schedule D, 2025). If line 16 is a loss, line 21 allows the smaller of the loss or "($3,000), or if married filing separately, ($1,500)". The rest carries over. Publication 550: "When you carry over a loss, it remains long-term or short-term", and "use your short-term capital losses first" when you work out what carries over (Publication 550, 2025). Section 9 of the Tax summary follows the steps of that worksheet.

0%, 15% and 20%: 2026 thresholds

Long-term gains and qualified dividends sit on top of your other taxable income. The rate depends on where they land. These are the 2026 amounts from Rev. Proc. 2025-32, section 4.03 (taxable income):

Filing status (2026)0% up to15% up to20% aboveNIIT threshold (MAGI)
Single$49,450$545,500$545,500$200,000
Married filing jointly$98,900$613,700$613,700$250,000
Married filing separately$49,450$306,850$306,850$125,000
Head of household$66,200$579,600$579,600$200,000
Qualifying surviving spouse$98,900$613,700$613,700$250,000

The Rates tab also holds the 2025 figures from IRS Topic 409 ($48,350 / $96,700 / $64,750 for the 0% rate; $533,400 single, $300,000 married filing separately, $600,050 joint, $566,700 head of household for 15%), so you can check a return you are filing now. The sheet runs the IRS Qualified Dividends and Capital Gain Tax Worksheet line by line with the amounts for the year you pick. Short-term gains get no special rate: "Net short-term capital gains are subject to taxation as ordinary income at graduated tax rates" (Topic 409). Type your marginal rate and the sheet applies it.

$0k$50k$100k$150k$200kFictional example, single: taxable income $191,5100% band ends at $49,450Head-of-household case: taxable income $71,0000% band ends at $66,200

Ordinary taxable income (worksheet line 5)Gains and qualified dividends in the 0% bandGains and qualified dividends taxed at 15%End of the 0% band

3.8% net investment income tax

The NIIT is 3.8% "on the lesser of their net investment income, or the amount by which their modified adjusted gross income exceeds the statutory threshold amount" (IRS, Net Investment Income Tax). The thresholds are set in IRC section 1411(b): $250,000 for a joint return or surviving spouse, half of that ($125,000) for married filing separately, and $200,000 in any other case. The IRS adds that they "are not indexed for inflation" (IRS NIIT questions and answers). Net investment income includes capital gains. The sheet adds your Form 1040 line 7a amount to the MAGI and other investment income you enter.

Worked example from the sample data

The fictional investor files single for 2026, has $172,000 of other taxable income, $1,500 of qualified dividends, $650 of capital gain distributions, a $1,500 long-term carryover from 2025 and a 24% marginal rate. The log has 11 sales. They land in these boxes:

BoxSales(d) Proceeds(e) Basis(g) Adj.(h) Gain/loss
A4$22,500$19,400$600$3,700
D4$53,460$40,400$0$13,060
E1$10,200$11,900$0−$1,700
G1$3,000$3,900$0−$900
K1$8,800$4,100$0$4,700

A loss year

Run the same sheet with a loss. Fictional case, single, 2026: a short-term loss of $9,000, a $500 short-term carryover, a long-term gain of $2,000 and a long-term loss of $2,500. Line 7 is −$9,500, line 15 is −$500 and line 16 is −$10,000. Line 21 allows a $3,000 deduction. At a 22% marginal rate that saves about $660. The other $7,000 carries to 2027: $6,500 short-term and $500 long-term, because short-term losses are used first.

When part of the gain is taxed at 0%

A fictional head of household with $50,000 of other taxable income, $1,000 of qualified dividends and a $20,000 long-term gain has taxable income of $71,000. The 0% band for that status ends at $66,200, so $16,200 is taxed at 0% and only $4,800 at 15% ($720.00). This is the lower bar in the chart above.

Formulas used

Exact formulas from the blank tabs (row 5 of Sales log; the Tax summary cells named). Functions used: SUMIFS, COUNTIF, COUNTA, EDATE, INDEX, MATCH, IFERROR, MID, MIN, MAX, IF, AND, OR, ISNUMBER, N, SUM.

FieldFormula
Row check (Sales log P5)=IF(COUNTA(A5,C5:G5)=0,"",IF(AND(ISNUMBER(D5),ISNUMBER(E5),ISNUMBER(F5),OR(K5="Short-term",K5="Long-term",AND(ISNUMBER(C5),D5>=C5))),"OK","Check this row"))
Days held (L5)=IF(AND(ISNUMBER(C5),ISNUMBER(D5)),D5-C5,"")
Term: short or long (M5)=IF(P5<>"OK","",IF(K5="Long-term","Long",IF(K5="Short-term","Short",IF(D5>EDATE(C5,12),"Long","Short"))))
Gain or loss, Form 8949 column (h) (N5)=IF(P5="OK",E5-F5+N(G5),"")
Form 8949 box (O5)=IF(P5="OK",MID(IF(M5="Short",IF(J5="Yes","GHI","ABC"),IF(J5="Yes","JKL","DEF")),IF(I5="Basis reported to IRS",1,IF(I5="Basis not reported to IRS",2,3)),1),"")
Box A total, column (h) (Tax summary F26)=SUMIFS('Sales log'!$N$5:$N$504,'Sales log'!$O$5:$O$504,"A")
Schedule D line 16 (B59)=$B$52+$B$58
Schedule D line 21, loss limit (B60)=IF($B$59<0,-MIN(-$B$59,N($B$20)),0)
Worksheet line 3, net capital gain (B66)=IF(AND($B$58>0,$B$59>0),MIN($B$58,$B$59),0)
Worksheet line 9, taxed at 0% (B72)=$B$70-$B$71
Worksheet line 17, taxed at 15% (B79)=MIN($B$74,$B$78)
Worksheet line 20, taxed at 20% (B81)=$B$73-$B$72-$B$79
NIIT (B88)=0.038*MIN($B$85,$B$87)
Short-term carryover to next year (B107)=IF($B$59<0,MAX(0,$B$104-$B$106),0)

Common mistakes

Limits

FAQ

How do I calculate capital gains tax in Excel?

Put one sale per row with the date acquired, date sold, proceeds and cost basis. Gain or loss is proceeds minus basis plus any adjustment, such as a wash sale disallowed loss. Use =IF(sold>EDATE(acquired,12),"Long","Short") for the holding period, total short-term and long-term rows with SUMIFS, net them as Schedule D does, then split long-term gains into the 0%, 15% and 20% layers. This template does all of it with visible formulas.

What are the capital gains tax rates for 2026?

Long-term gains are taxed at 0%, 15% or 20% depending on taxable income. For 2026, Rev. Proc. 2025-32 sets the maximum zero-rate amount at $49,450 (single and married filing separately), $98,900 (married filing jointly and surviving spouse) and $66,200 (head of household). The 15% rate runs up to $545,500, $613,700, $306,850 (married filing separately) and $579,600 (head of household). Short-term gains are taxed as ordinary income.

How are short-term and long-term gains and losses netted?

Short-term gains and losses, plus any short-term carryover, are combined first (Schedule D line 7). Long-term items, capital gain distributions and any long-term carryover are combined next (line 15). The two results are then combined on line 16. A long-term gain is only taxed at the lower rates to the extent it exceeds any net short-term loss.

How much capital loss can I deduct in a year?

IRS Topic 409 says the deductible excess loss is "the lesser of $3,000 ($1,500 if married filing separately) or your total net loss shown on line 16 of Schedule D". The rest carries forward to later years and keeps its short-term or long-term character. The template works out the carryover with the logic of Publication 550's Capital Loss Carryover Worksheet.

Do capital gains count for the 3.8% net investment income tax?

Yes. Net investment income includes capital gains. The 3.8% tax applies to the smaller of net investment income or the amount by which modified adjusted gross income exceeds $200,000 (single or head of household), $250,000 (married filing jointly or qualifying surviving spouse) or $125,000 (married filing separately). The IRS notes these thresholds "are not indexed for inflation".

Which Form 8949 box should I check?

It depends on the term, whether your Form 1099-B or 1099-DA shows basis reported to the IRS, and whether the asset is a digital asset. Short-term: A, B or C (G, H or I for digital assets). Long-term: D, E or F (J, K or L for digital assets). The first letter of each trio means basis was reported, the second means it was not, the third means no form. The template picks the box for every row.

Related tools and templates

Educational template only, not tax, legal or investment advice. It produces an estimate, not a tax return. Example data is fictional: the investor, assets, dates, amounts and income are made up to show the formulas. Tax rules change; check the figures on irs.gov for your year and ask a qualified tax professional about your situation. Rules and figures are quoted from IRS Topic 409, Publication 550 (2025), the 2025 Instructions for Form 8949, Schedule D (2025), the 2025 Form 1040 instructions, Rev. Proc. 2025-32, the IRS net investment income tax pages and IRC section 1411, all retrieved on 7 November 2026.