WhatsApp and email answered by the lawyer himself.Book a call

IRPF Calculation

How to Calculate the Capital Gain on Your Main Residence: Complete Guide with Examples

Before applying the reinvestment exemption, you need to know precisely how much tax the sale of your home will trigger. This guide explains step by step the calculation formula, which costs can be deducted, when improvements count, the reduction coefficients for older properties, and three full numerical examples.

By Jacob Salama, Main Home Reinvestment Lawyer · Málaga Bar 11.294Updated 1 October 202517 min read
⚖️ Legal notice: This article is for information purposes only and does not constitute personalised tax advice. Tax legislation may change. Please consult a qualified professional before making any tax decisions.

1. The basic capital-gain formula

The capital gain (or loss) generated by the sale of a property is calculated under article 35 of Law 35/2006 (IRPF) using the following formula:

Capital gain = Transfer value − Acquisition value

Where:

  • Transfer value: what the seller actually obtains from the sale, after deducting the costs they bear.
  • Acquisition value: what the buyer paid in their day for the property, including all costs inherent to the purchase, plus the improvements made, minus the depreciation if the property was let.

If the result is positive, there is a capital gain that will be taxed in the IRPF savings base. If it is negative, there is a capital loss that may be offset against the taxpayer's other gains in the following four tax years.

Gains and losses on transfers are offset against each other within the savings base; a negative balance may also offset up to 25% of the positive balance of income from movable capital of the same year, and the rest in the following four years (art. 49 LIRPF).

📌 Important: the capital gain and the amount to reinvest are different things. The amount obtained for reinvestment is the transfer value (price less selling costs) less the outstanding principal of the loan used to buy the home, if any (art. 41.1). That loan does not reduce the gain.

2. Transfer value: what it is and how to calculate it

The transfer value is the actual amount for which the property was sold, provided it is not lower than market value, in which case market value prevails (art. 35.2 LIRPF).

Sale price

The sale price is the one stated in the public deed of sale or, failing that, in the private contract. It includes any amount agreed to be paid to the seller, whether in cash, cheque, transfer or any other means of payment.

What if the declared price is lower than the real value?

If the Administration considers that the actual sale price was higher than the declared one (for example, through a value verification), the verified value will be taken. This is especially relevant in transactions between related parties or in property markets where market prices exceed declared ones.

⚠️ Caution with deferred sale price: When the sale price is collected in several instalments (deferred price), the transfer value is the total agreed price, regardless of when the different parts are collected. However, the gain is allocated to the tax period in which the sale takes place (unless the option for allocating gains by collection instalments is chosen, art. 14.2.d LIRPF).

3. Costs deductible from the transfer value

From the sale price, the costs and taxes inherent to the transfer paid by the seller are deducted. The result is the net transfer value.

Cost Deductible? Notes
Tax on the Increase in Value of Urban Land (municipal plusvalía) ✅ Yes, always Only if the seller pays it. If passed on to the buyer contractually, it is not deductible for the seller.
Estate-agent commission ✅ Yes Only the part paid by the seller. Must be documented with an invoice.
Notary fees (deed of sale) ✅ Yes, if paid by the seller The seller may agree to bear the costs of the deed. If borne by the buyer, not deductible for the seller.
IBI for the year of sale❌ NoAn ownership cost, not inherent in the transfer.
Mortgage cancellation costs at the Land Registry ✅ Yes Notary and registry of the deed of mortgage cancellation.
Valuation for mortgage cancellation ⚠️ Debatable The DGT does not always accept it. It is advisable to have the invoice and argue it is inherent to the transfer.
Community fees or outstanding levies borne by the seller ❌ No These are ownership costs, not inherent to the transfer.
3% withheld by the buyer from non-resident sellers (IRNR) ❌ No It is a payment on account by the seller, not a transfer cost.

Municipal plusvalía: when it is deductible and when it is not

The Tax on the Increase in Value of Urban Land (IIVTNU), known as the municipal plusvalía, has the seller as the taxpayer in onerous transfers. Therefore, in principle, the seller always pays it and it is always deductible from the transfer value for IRPF purposes.

However, in practice it is often agreed that the buyer pays it. In that case, the seller cannot claim the deduction in IRPF.

If the seller declares the municipal plusvalía but does not actually pay it (because of deferment), the law only allows it to be deducted once paid (art. 35.2 LIRPF), which may require amending the return.

The estate-agent commission

The DGT has confirmed in multiple binding rulings that the estate-agent commission paid by the seller is deductible from the transfer value, provided it is properly documented (invoice or equivalent).

"The transfer value shall be the actual amount for which the disposal was made. From this value, the costs and taxes referred to in letter b) of section 1 shall be deducted insofar as they are borne by the transferor."

On costs inherent in the sale see V1177-20 (registry cancellation of the mortgage and municipal plusvalía).

4. Acquisition value: all the components

The acquisition value is the price that the current seller paid in their day for the property, plus the purchase costs and the improvements made, less the depreciation if the property was let.

Acquisition value = Purchase price + Purchase costs + Improvements − Depreciation

The purchase price

This is the one set out in the public deed of sale or equivalent document at the time of acquisition. If the property was inherited, the acquisition value is the value declared in the Inheritance Tax (capped at the market value on the date of death). If it was a gift, the value of the gift declared.

Monetary updating: does it still exist?

Before 2015, there were monetary update coefficients that corrected the effect of inflation on the acquisition value of properties. These coefficients were eliminated by Law 26/2014 with effect from 1 January 2015. From that year, the acquisition value of properties is no longer updated for inflation, which represents a tax penalty for long-term owners.

🚨 Important since 2015: There are no longer monetary update coefficients for property, whatever its purchase date. The acquisition value is the nominal price paid, without correction for inflation. Only the transitional regime of reduction coefficients for properties acquired before 31 December 1994 remains.

5. Costs included in the acquisition value

Art. 35.1.b) LIRPF allows the "costs and taxes inherent to the acquisition" paid by the acquirer to be included in the acquisition value. The full list is:

Cost Includable? Notes
Transfer Tax (ITP) — for second-hand homes ✅ Yes The rate varies by autonomous community.
VAT — for new homes ✅ Yes Currently 10% for main residence (or 4% for social housing).
Stamp Duty (AJD) ✅ Yes Applies to new homes alongside VAT. Since 10 November 2018 (Royal Decree-law 17/2018), the bank pays it on mortgage loans, but if the buyer paid it in their day, it does count.
Notary fees (deed of purchase) ✅ Yes Those paid by the buyer at the time of purchase.
Land Registry registration fees ✅ Yes Registry fees for recording the purchase.
Agency fees ✅ Yes If an agency was hired for the purchase.
Property valuation (for the mortgage) ⚠️ Debatable It is a cost of the loan.
Mortgage opening commission ⚠️ Controversial A cost of the loan, not of the purchase. Better not to include it.
Mortgage loan interest ❌ No Interest is deductible under the main-residence deduction (transitional regime for acquisitions before 2013), but does not form part of the acquisition value.
Life insurance linked to the mortgage ❌ No Not a cost inherent to the acquisition of the property.
Community fees or IBI during ownership ❌ No These are maintenance or ownership costs, not acquisition costs.
📌 Practical tip: Keep all documents and invoices for purchase costs from day one. Over the years it is easy to lose receipts for AJD, notary or registry, and without them the AEAT may refuse their inclusion in the acquisition value.

6. Improvements vs. repairs: a crucial tax distinction

Improvements made to the property during the ownership period increase the acquisition value, thus reducing the capital gain. However, repairs and maintenance costs are not included in the acquisition value, although they may be deductible if the property has been let.

What is an improvement for tax purposes?

The distinction between improvement and repair is one of the most contentious in tax practice. Generally:

Item Type Effect on the gain Examples
Works that increase the surface area or built volume Improvement Increases acquisition value Extension of the flat, building a terrace, enclosing a balcony
Works that add new previously non-existent elements or installations Improvement Increases acquisition value Installation of air conditioning, heating where there was none, new lift
Refurbishment works that permanently improve the quality or category of the property Improvement (depending on the works and the evidence) Increases acquisition value Full kitchen or bathroom refurbishment with higher-quality materials; full renewal of installations
Replacement of damaged elements with equivalent ones Repair/maintenance Does not count (unless let) Replacing a broken boiler, repairing existing heating, painting the walls
Ordinary maintenance Maintenance Does not count Painting, replacement of small appliances, minor plumbing repairs

Improvements and repairs: the criterion

In general, improvements are works that increase the capacity or habitability of the property or lengthen its useful life; repairs and maintenance preserve normal use or correct damage.

How each job is classified depends on invoices and evidence.

The practical problem: mixed works

In practice, many works are "mixed": they contain both improvement and repair elements. In these cases, the DGT requires the taxpayer to differentiate in the invoice or in the works documentation what part corresponds to improvement (countable) and what part to repair (non-countable). If it is not possible to distinguish, the AEAT may reject all of the works as an improvement.

⚠️ Tip for mixed works: Ask your architect or contractor to clearly distinguish in the budget and invoices between "new works" (improvement) and "replacement of existing elements" (repair). This distinction can mean thousands of euros of difference in the capital gain.

When are improvements added to the acquisition value?

Improvements are added to the acquisition value in the year they are carried out. If depreciation is taken on the improvements (because of letting), it is also deducted from the acquisition value.

7. Depreciation if the property was let

If the property was let at any time during the ownership period, depreciation must be subtracted from the acquisition value when calculating the capital gain: at least the minimum depreciation, even if you never deducted it (art. 40.1 RIRPF).

The "minimum deducted" rule

Article 35.1 of the Act refers to the Regulation, which takes the minimum depreciation into account whether or not it was deducted (art. 40 RIRPF). For let properties, the Supreme Court held in judgment 1502/2025, of 20 November (appeal 7361/2023, ROJ STS 5416/2025), that a landlord with income from immovable capital need not apply the maximum 3 % depreciation and may apply the minimum when calculating acquisition value.

Minimum depreciation is always taken into account (art. 40.1 RIRPF).

Calculating depreciation on let properties

Deductible depreciation on a let property is 3 % of the higher of acquisition cost or cadastral value, excluding the land. The example uses that rate; under the judgment cited, minimum depreciation may be considered.

📌 Example: Property with an acquisition value of €200,000 (of which €50,000 is land and €150,000 is construction). It was let for 5 years. Cumulative depreciation = 150,000 × 3% × 5 years = €22,500. This amount is deducted from the acquisition value when calculating the capital gain.

8. Reduction coefficients: transitional regime for properties acquired before 31/12/1994

For properties acquired before 31 December 1994, there is a transitional regime (ninth transitional provision of the LIRPF) allowing reduction coefficients to be applied to the part of the gain generated before 20 January 2006. This regime reduces the taxation of gains accumulated over many years of ownership.

Conditions of the transitional regime

  • Only for assets acquired before 31 December 1994.
  • Cumulative limit: the regime only applies to the part of the gain corresponding to the period from acquisition to 19 January 2006. The gain after that date is taxed without reduction.
  • The regime applies while the total transfer values to which it has been applied since 1 January 2015 do not exceed €400,000; a sale that crosses the limit benefits in proportion. Sales before 2015 do not count.

Reduction coefficients for properties

For real estate, the part of the gain before 20 January 2006 is reduced by 11.11 % for each year of ownership over two. Ownership is counted in years from acquisition to 31 December 1996, rounded up. This means that:

  • If ownership at 31 December 1996 exceeded ten years, that part of the gain is not taxed.
  • Otherwise the reduction depends on the number of years.

Calculation formula with reduction

The calculation procedure is:

  1. Calculate the total gain: Transfer value − Acquisition value.
  2. Divide the gain into two parts:
    • Part 1: Gain generated up to 19/01/2006 = Total gain × (days from acquisition to 19/01/2006 / total days from acquisition to transfer).
    • Part 2: Gain generated from 20/01/2006 = Total gain − Part 1.
  3. On Part 1, reduce by 11.11 % for each year of ownership over two.
  4. Part 2 is taxed in full without reduction.
⚠️ The €400,000 limit: This limit is cumulative per taxpayer from 1 January 2015. If you have sold other assets with reduction since that date, you must monitor the remaining availability. The AEAT may request information on previous transfers with reduction.

Interaction with the reinvestment exemption

They are compatible. The DGT sets the order in V2227-23: first the part exempt through reinvestment, then the reduction on the non-exempt gain. The reinvested part of the transfer value that gives rise to the exemption does not count towards the €400,000 limit.

Jacob Salama, international tax lawyer, in his office

9. 2025 IRPF savings tax scale: rates applicable to the capital gain

The capital gain from the sale of properties is taxed in the IRPF savings taxable base, which has its own scale of progressive rates. For the 2025 tax year, the scale is:

Savings net taxable base Marginal state + regional rate Cumulative effective rate
Up to €6,000 19% 19%
From €6,000 to €50,000 21% 19% up to €6,000 + 21% on the excess
From €50,000 to €200,000 23% Cumulative for previous brackets + 23% on excess
From €200,000 to €300,000 27% Cumulative + 27% on excess
Over €300,000 30% Cumulative + 30% on excess

Tax payable on different gains

Capital gain Approximate IRPF charge Effective rate
€20,000€4,08020.4%
€50,000€10,38020.8%
€100,000€21,88021.9%
€150,000€33,38022.3%
€200,000€44,88022.4%
€300,000€71,88024.0%
€500,000€131,88026.4%
📌 Remember: The savings scale is progressive: not all the gain is taxed at the highest rate. Only the part exceeding each threshold is taxed at the corresponding rate. Use our savings calculator to work out the exact tax for your gain and the potential saving with the reinvestment exemption.

10. Practical example 1: standard case with no incidents

Case data

  • Property acquired in 2010 for €220,000
  • Purchase costs: ITP (8%) = €17,600; notary = €900; registry = €400; agency = €350. Total purchase costs: €19,250
  • Improvements made in 2018: full refurbishment of kitchen and bathrooms = €18,000
  • The property was never let
  • Sale price in 2025: €380,000
  • Sale costs: municipal plusvalía = €4,200; agency commission = €7,600; notary (borne by seller) = €600

Calculation

ItemAmount
Sale price€380,000
Less: municipal plusvalía− €4,200
Less: agency commission− €7,600
Less: notary (borne by seller)− €600
= Net transfer value€367,600
Purchase price (2010)€220,000
Plus: purchase costs+ €19,250
Plus: improvements (2018)+ €18,000
Less: depreciation€0
= Acquisition value€257,250
CAPITAL GAIN€110,350

Tax payable (without the reinvestment exemption)

  • First €6,000: 6,000 × 19% = €1,140
  • From €6,000 to €50,000 (€44,000): 44,000 × 21% = €9,240
  • From €50,000 to €110,350 (€60,350): 60,350 × 23% = €13,880.50
  • Total IRPF: €24,260.50
✅ Saving with the full reinvestment exemption: €24,260.50

11. Practical example 2: property with letting and improvements

Case data

  • Property acquired in 2005 for €150,000 (of which €40,000 corresponds to land)
  • Purchase costs: ITP (7%) = €10,500; notary + registry + agency = €1,800. Total purchase costs: €12,300
  • Let for 6 years (2009–2015): depreciation of 3% on €110,000 (construction value) = €3,300/year × 6 years = €19,800 cumulative depreciation
  • Improvements made in 2016: installation of central heating and bathroom refurbishment = €22,000
  • Sale price in 2025: €290,000
  • Sale costs: municipal plusvalía = €3,800; agency = €5,800. Total sale costs: €9,600

Calculation

ItemAmount
Sale price€290,000
Less sale costs− €9,600
Net transfer value€280,400
Purchase price€150,000
Plus purchase costs+ €12,300
Plus improvements (2016)+ €22,000
Less cumulative depreciation− €19,800
Acquisition value€164,500
CAPITAL GAIN€115,900

Tax payable (without exemption)

  • 6,000 × 19% = €1,140
  • 44,000 × 21% = €9,240
  • 65,900 × 23% = €15,157
  • Total IRPF: €25,537
⚠️ Note: In this case, if the property was the taxpayer's main residence from 2016 and they reinvest the amount obtained in another main residence within the 2-year period, the €25,537 would be exempt. The depreciation deducted during the letting (2009-2015) increased the gain by €19,800, generating extra tax of around €4,554 that would not exist if the property had not been let.

12. Practical example 3: property acquired before 1994 with reduction coefficients

Case data

  • Property acquired on 1 March 1990 for €30,000 (converted from pesetas)
  • Purchase costs in 1990: €2,500
  • Sale price in October 2025: €320,000
  • Sale costs: €8,000
  • No letting or significant improvements
  • The taxpayer has not sold other assets with reduction since 2015, so the full €400,000 limit is available

Step 1: Calculation of the total gain

  • Net transfer value: 320,000 − 8,000 = €312,000
  • Acquisition value: 30,000 + 2,500 = €32,500
  • Total gain: 312,000 − 32,500 = €279,500

Step 2: Temporal split of the gain

  • Days from acquisition (01/03/1990) to transfer (01/10/2025): 12,998 days
  • Days from acquisition (01/03/1990) to 19/01/2006: 5,803 days
  • Gain up to 19/01/2006 (Part 1): 279,500 × (5,803 / 12,998) = €124,784
  • Gain from 20/01/2006 (Part 2): 279,500 − 124,784 = €154,716

Step 3: Application of the reduction coefficient on Part 1

Ownership to 31/12/1996: 6 years and 10 months, rounded up to 7. Years over two: 5. Reduction: 5 × 11.11 % = 55.55 %.

  • Reduction on Part 1: 124,784 × 55.55% = €69,317
  • Reduced Part 1 (taxable): 124,784 − 69,317 = €55,467
  • Part 2 (taxable in full): €154,716
  • Total gain subject to IRPF: €210,183

Tax payable without the reinvestment exemption

  • 6,000 × 19% = €1,140
  • 44,000 × 21% = €9,240
  • 150,000 × 23% = €34,500; 10,183 × 27% = €2,749
  • Total IRPF: €47,629
✅ Effect of the reduction: without it, the €279,500 gain would be taxed at €66,345. With it, €47,629. If the whole amount obtained is also reinvested in time in another main residence, the gain is exempt and no tax is due.

13. DGT 2025 doctrine: relevant binding rulings

Order between reinvestment and reduction coefficients

V2227-23: first the exemption, then the reduction.

Costs inherent in the sale

V1177-20: those directly related to the purchase or sale, including the registry cancellation of the mortgage and the municipal plusvalía.

14. Common mistakes in calculating the capital gain

❌ Mistake 1 — Not including all purchase costs: Many taxpayers only include the purchase price and forget the ITP, notary, registry or agency. These costs can amount to between 8% and 12% of the purchase price.
❌ Mistake 2 — Including repairs as improvements: Repairs do not increase the acquisition value. Including them may lead to a parallel assessment by the AEAT with surcharges and interest.
❌ Mistake 3 — Not deducting depreciation from letting: if the property was let, at least the minimum depreciation must be deducted.
❌ Mistake 4 — Not applying reduction coefficients for pre-1994 properties: If you leave the reduction out of your return, you pay too much. The €400,000 cumulative sale-price limit is an element requiring monitoring.
❌ Mistake 5 — Confusing the gain and the amount obtained: for the proportional exemption the denominator is the amount obtained (transfer value less, where applicable, the outstanding purchase loan), not the gain.

15. Conclusion: why prior calculation is fundamental

Accurate calculation of the capital gain is the starting point for any tax planning around the sale of a main residence. Without knowing the exact amount of the gain, you cannot:

  • Determine the potential tax saving with the reinvestment exemption.
  • Correctly calculate the minimum reinvestment needed for full exemption.
  • Assess whether it is worth reinvesting or absorbing the tax cost.
  • Plan the sale at the most favourable moment (especially with reduction coefficients and the €400,000 limit).
📞 Want to calculate your capital gain and exemption saving precisely? Our team can help you identify all deductible costs, correctly apply the reduction coefficients and calculate the minimum reinvestment needed for full exemption.

Tell us your case

Official sources

Working out your taxable gain in Spain

How do I calculate the capital gain on my Spanish home?

Subtract the acquisition value from the transfer value. The acquisition value is the purchase price plus purchase costs and improvements, less depreciation if the home was let. The transfer value is the actual price less the sale costs and taxes that you, as seller, paid.

Is the municipal plusvalía deducted when calculating my income tax gain?

Yes, if you as the seller paid it: it reduces the transfer value. If you agreed with the buyer that the buyer would pay it, you cannot deduct it. The same logic applies to the estate-agent commission, which needs an invoice and counts only for the part you paid.

Does Spain adjust my purchase price for inflation when I sell?

No. Monetary update coefficients for property were abolished with effect from 1 January 2015, so your nominal purchase price is used. The only surviving relief of that kind is the transitional regime for property acquired before 31 December 1994, subject to a €400,000 limit on accumulated sale prices.

I rented out the home for a few years. Does that change the gain?

Yes. Depreciation from the letting period reduces the acquisition value and therefore increases the gain. At least the minimum depreciation is taken into account even if you never claimed it in your returns (article 40.1 of the Regulation).

Jacob Salama

Jacob Salama

Main Home Reinvestment Lawyer · Málaga Bar 11.294

Member of the Málaga Bar (no. 11.294) and managing partner of SALAMA LEGAL, S.L.P. He advises individuals on Spanish income tax and cross-border taxation and reviews the content of this website himself.

About the lawyer (ES) · Book a call

A note on sources. Some references on this page (rulings, decisions or draft rules) could not be checked against their official text. Please confirm them before making a decision.

Last reviewed: 1 October 2025. General information on Spanish law in force; it does not replace advice on your specific case.

Further reading

Talk to the lawyer

Before you sign the sale, let a lawyer check your exemption

One wrong date or figure can cost you the whole exemption. We review your case and tell you how much you can save.

Book a callWhatsAppContact form
Book a callWhatsApp