Farmland / ranch

Capital Gains Tax on Selling Farmland or a Ranch

Short answer: farmland held more than a year produces long-term capital gain at 0%, 15% or 20%. The depreciation you took on buildings and improvements comes back as unrecaptured Section 1250 gain at up to 25%, depreciated equipment sold in the deal creates ordinary income, and the 3.8% NIIT may apply if you do not materially participate.

Retiring farmers and heirs often sell once, and that single year of income sets how much Social Security is taxable and your Medicare premiums two years later. The calculator prices all of it.

By Hans Goldstein, EA, Enrolled Agent, enrolled to practice before the IRS. Updated December 2026.

2027 federal brackets (IRS Rev. Proc. 2026-35), SSA Section 86 thresholds, CMS 2027 Medicare premiums and IRMAA tiers, state rates as of December 2026. Estimates, not tax advice.

Worked example

A married couple, 67 and 65, sell a farm for $1,800,000. Their basis is $220,000, they have taken $60,000 of depreciation on buildings and pay $72,000 in selling costs. They collect $48,000 of Social Security and have $40,000 of other income.

Worked exampleAmount
Taxable gain$1,568,000
Federal tax on the gain$301,825
Net investment income tax (3.8%)$52,478
California tax on the gain$162,330
Tax most calculators show$516,633
Extra tax on Social Security the sale makes taxable ($17,800 more taxable)$8,549
Medicare Part B + D surcharge two years later$14,371
Real cost$539,553

What is taxed when a farm sells

A farm sale mixes several kinds of property. Land held over a year is long-term capital gain. Buildings and land improvements that you depreciated create unrecaptured Section 1250 gain, up to 25%. Machinery and equipment sold in the deal create Section 1245 recapture, ordinary income. Raised breeding livestock and timber have their own rules. The purchase price allocation sets each amount; get it in writing before closing.

Why farm sales often land in a Medicare tier

A land-rich, cash-poor farmer might have $40,000 of income most years and then a seven-figure gain one year. That year decides how much Social Security is taxable and sets Medicare Part B and D premiums two years later. Farmers who sell at 63 or older are within range. Spreading the gain over years, through an installment sale to the next generation, is often a better fit than one large check. See selling the family farm: taxes and selling farmland in California.

Frequently asked questions

How much is capital gains tax on selling farmland?

Long-term capital gain is taxed at 0%, 15% or 20% federally in 2027, plus state tax. Depreciation recapture on buildings is taxed at up to 25%, and equipment recapture is ordinary income. Passive owners also pay 3.8% NIIT.

Is there a capital gains exemption for farmers?

There is no general exemption for farmland. There are deferral options such as Section 1031 exchanges and installment sales, and a newer rule lets some sellers of farmland to qualified farmers pay the tax over four years. Ask your CPA whether you qualify.

Do I pay NIIT when I sell the farm?

The 3.8% NIIT does not apply to gain on property used in a business you materially participate in, such as active farming. It can apply to a rented-out or inherited farm that you do not actively operate.

How is inherited farmland taxed on sale?

Your basis is generally its fair market value at the date of death, and the sale is long-term. Only the gain after the date of death is taxed.

Does selling the farm affect Social Security and Medicare?

The gain raises your income, which can make up to 85% of your Social Security taxable that year and raise your Medicare surcharge two years later. The calculator prices both.

Can I defer the tax on selling farmland?

Common ways include a Section 1031 exchange into other real property, an installment sale, and for some sales to qualified farmers, a four-year payment of the tax. Each has rules, so a CPA should review before you sign.

Run it on your real return

A free 15-minute call with Hans Goldstein: which levers fit your sale, what the Social Security and Medicare effects look like on your actual numbers, and what to ask your CPA.

Book 15 minutes 213-414-2808

Educational estimate, not tax, legal or financial advice. Figures use 2027 federal brackets and thresholds (IRS Rev. Proc. 2026-35), the Social Security benefit-taxation rules in IRC Section 86, CMS 2027 Medicare premiums and IRMAA tiers, and state rates as of December 2026 (California uses the FTB 2026 schedule until the 2027 schedule is published). Later Medicare years hold the 2027 tiers flat. Your CPA should confirm any figure before you act. By Hans Goldstein, EA, Enrolled Agent (enrolled to practice before the IRS), reviewed December 2026.

Run my numbers Book 15 min Call

Hans Goldstein is an Enrolled Agent, enrolled to practice before the Internal Revenue Service. Not affiliated with or endorsed by the IRS. General education, not tax or legal advice for your situation.