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.
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.
| Asset (fictional) | Acquired | Sold | Proceeds | Basis | Adj. | Term | Gain/loss | Box |
|---|---|---|---|---|---|---|---|---|
| Example Fund A (ETF) | 14 Mar 2023 | 10 Feb 2026 | $18,400 | $12,000 | — | Long | $6,400 | D |
| Example Stock B, lot 1 | 2 Jun 2025 | 20 Jan 2026 | $9,100 | $6,500 | — | Short | $2,600 | A |
| Example Stock C, lot 1 | 7 Apr 2025 | 3 Mar 2026 | $3,800 | $5,000 | — | Short | −$1,200 | A |
| Example Stock C, lot 2 (wash sale) | 15 Sep 2025 | 10 Mar 2026 | $2,100 | $2,700 | $600 | Short | $0 | A |
| Example Stock D, lot 1 (exactly 1 year) | 15 May 2025 | 15 May 2026 | $7,500 | $5,200 | — | Short | $2,300 | A |
| Example Stock D, lot 2 | 15 May 2025 | 18 May 2026 | $7,560 | $5,200 | — | Long | $2,360 | D |
| Example Bond Fund E (bought 2010) | 2 Aug 2010 | 12 Jun 2026 | $10,200 | $11,900 | — | Long | −$1,700 | E |
| Inherited Stock F | Inherited | 1 Jul 2026 | $15,000 | $14,200 | — | Long | $800 | D |
| Example Coin G | 20 Feb 2024 | 5 Aug 2026 | $8,800 | $4,100 | — | Long | $4,700 | K |
| Example Coin H | 12 Jan 2026 | 30 Apr 2026 | $3,000 | $3,900 | — | Short | −$900 | G |
| Example Stock B, lot 2 | 1 Nov 2023 | 14 Sep 2026 | $12,500 | $9,000 | — | Long | $3,500 | D |
What's inside the spreadsheet
| Tab | What you type | What it calculates |
|---|---|---|
| Start here | Nothing | Steps, the rules built in, colour key, limits, disclaimer |
| Tax summary | Tax year (2026 or 2025), filing status, other taxable income, qualified dividends, capital gain distributions, last year's carryovers, your marginal rate, MAGI, other investment income | Totals 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 log | 500 rows: description, quantity, date acquired, date sold, proceeds, cost basis, adjustment (wash sale), code, 1099 reporting type, digital asset yes/no, term override | Days held, short or long term, gain or loss (column h), Form 8949 box, a row check that turns red on bad rows |
| Rates | Nothing (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 summary | Already filled with fictional sales | The same formulas, so you can see a full result first |
How to use it
- 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.
- 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.
- 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.
- 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".
- 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.
- 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-DA | Short-term | Short-term digital asset | Long-term | Long-term digital asset | Schedule D line |
|---|---|---|---|---|---|
| Shows basis reported to the IRS | A | G | D | J | 1b / 8b |
| Basis not reported to the IRS | B | H | E | K | 2 / 9 |
| No form received | C | I | F | L | 3 / 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 to | 15% up to | 20% above | NIIT 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.
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:
| Box | Sales | (d) Proceeds | (e) Basis | (g) Adj. | (h) Gain/loss |
|---|---|---|---|---|---|
| A | 4 | $22,500 | $19,400 | $600 | $3,700 |
| D | 4 | $53,460 | $40,400 | $0 | $13,060 |
| E | 1 | $10,200 | $11,900 | $0 | −$1,700 |
| G | 1 | $3,000 | $3,900 | $0 | −$900 |
| K | 1 | $8,800 | $4,100 | $0 | $4,700 |
- Short-term: $4,900 of gains and $2,100 of losses net to $2,800 (line 7). The wash-sale row (Example Stock C, lot 2 (wash sale)) lost $600, but the $600 adjustment brings it to $0.
- Long-term: $17,760 of gains, $1,700 of losses, $650 of distributions and the −$1,500 carryover give $15,210 (line 15). Line 16: $18,010.
- Rate layers: taxable income is $191,510. Ordinary income fills the first $174,800, well past the $49,450 end of the 0% band. So the $15,210 net capital gain plus $1,500 of qualified dividends ($16,710) is all taxed at 15%: $2,506.50.
- Short-term tax: $2,800 × 24% = $672.00.
- NIIT: MAGI of $189,600 + $18,010 = $207,610, which is $7,610 over the $200,000 threshold. Net investment income is $20,410. 3.8% of the smaller amount, $7,610, is $289.18.
- Total estimate: $3,467.68. Without the NIIT, the tax on short-term gains, long-term gains and qualified dividends is 17.6% of the line 16 gain.
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.
| Field | Formula |
|---|---|
| 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
- Using the settlement date. Publication 550: for traded securities the holding period "begins the day after the trade date you bought the securities, and ends on the trade date you sold them". Type trade dates.
- Selling one day too early. Exactly one year is still short-term. The example's Stock D lot 1 shows it.
- Typing the wash sale loss as a negative. The disallowed loss goes in column (g) as a positive number with code W. Then add it to the basis of the replacement shares. See the tax-loss harvesting spreadsheet to plan around the 30-day window.
- Forgetting last year's carryover. It goes on Schedule D line 6 or 14 and reduces this year's gains first.
- Treating crypto like stock boxes. From the 2025 forms, digital assets use boxes G to L, not C or F. Track coin lots in the crypto tax spreadsheet and bring the totals here.
- Reading the estimate as your bill. The sheet leaves out state tax, AMT and the special 25% and 28% rates, and it uses a single marginal rate.
Limits
- Federal individual rules only. No state tax, no alternative minimum tax.
- Not covered: 28% collectibles gain and section 1202 gain, 25% unrecaptured section 1250 gain, the home sale exclusion, Forms 4684, 4797, 6252, 6781 and 8824, and K-1 amounts. If you have any of these, the IRS sends you to the Schedule D Tax Worksheet instead.
- Short-term gains use the one marginal rate you type. A gain that crosses into the next bracket is slightly understated. The worksheet's "smaller of line 23 or line 24" step (regular tax if lower) is not modelled.
- The sheet does not choose lots (FIFO or specific identification) and does not detect wash sales. Enter what your broker or your own records show.
- Tested by recalculating in LibreOffice and checking 1,399 outputs against a separate Python model (see sources). Every function used also exists in Excel 2016+ and Google Sheets, but the file was not opened in those programs for this check.
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
- Capital gains tax calculatorQuick estimate for one sale
- Cost basis spreadsheetLots, average cost and adjusted basis
- Tax-loss harvesting spreadsheetLosses to harvest and wash sale dates
- Crypto tax spreadsheetCoin trades, lots and gains
- XIRR spreadsheetYour personal rate of return
- All templatesFree spreadsheets
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.