Guides · 2026–27 tax year
The 30-Day Rule for Shares (Bed and Breakfasting) Explained
Selling shares and buying them straight back sounds like an easy way to use your tax-free allowance. HMRC's 30-day rule stops that from working. Here's what the rule does, with simple examples.

Please read
This guide is for general information only. It is not financial or tax advice, and it may contain mistakes or leave out rules that apply to you. It covers shares and funds only, not property, crypto or business assets. Check with HMRC or a qualified adviser before making decisions.
The rule in one sentence
If you sell shares and buy the same shares back within the next 30 days, HMRC matches your sale with the shares you bought back, not with the shares you already had.
That means your gain (or loss) is worked out using the price you bought back at, not the average cost of your older shares. It's often called the "bed and breakfast" rule.
Why the rule exists
People used to sell shares on the last day of the tax year (the "bed") and buy them back the next morning (the "breakfast"). This let them use their tax-free allowance and reset the cost of their shares to a higher price, without really changing their investments.
The 30-day rule, in place since 1998, stops this. A sale followed by a quick buy-back is treated as if you never really sold.
Which purchases count
A purchase is matched with your earlier sale when all of these are true:
- It's the same shares: the same company and the same type of share, or the same fund.
- It's bought by you, in an ordinary taxable account. Purchases by your husband, wife or civil partner, or inside your ISA or pension, don't count.
- It's bought in the 30 days after the day you sold. If you sell on 3 April, purchases from 4 April to 3 May count.
This rule comes second in HMRC's order: shares bought on the same day as the sale are matched first. Anything not matched by either rule comes from your Section 104 pool at its average cost. Shares you bought before the sale are part of that pool, so they aren't affected by this rule.
Example: buying all the shares back
Say you own 1,000 shares that cost you £5,000 in total, an average of £5 each. They're now worth £8 each. You'd like to use your £3,000 allowance on the gain, so you sell and buy back a week later. (Fees are left out to keep it simple.)
3 April: sell 1,000 shares at £8. 10 April: buy 1,000 back at £8.10
- Money from the sale
- £8,000
- Cost used: the 1,000 shares bought back on 10 April
- −£8,100
- Result: a loss, not the gain you expected
- −£100
Because the sale is matched with the shares you bought back, the £3,000 gain you wanted to use simply doesn't happen. You're left holding 1,000 shares with the same £5,000 cost as before, so the gain is still waiting for you when you eventually sell.
What if you'd waited until 4 May (31 days later)?
- Money from the sale
- £8,000
- Cost used: average cost from the pool, 1,000 × £5
- −£5,000
- Gain, covered by the £3,000 allowance
- £3,000
The new shares now go into your pool at £8,100, so your future gain is smaller. The catch: for those 31 days you're out of the market, and the price could rise before you buy back.
Example: buying some of them back
If you buy back fewer shares than you sold, only that number is matched with the new purchase. The rest of the sale uses your average cost as normal.
3 April: sell 1,000 at £8. 20 April: buy 400 back at £8.20
- 400 shares matched with the buy-back: £3,200 − £3,280
- −£80
- 600 shares from the pool: £4,800 − (600 × £5)
- £1,800
- Total gain on the sale
- £1,720
Afterwards you hold 400 shares with a cost of £2,000 (still £5 each). The 400 you bought back were used up by the matching.
It works for losses too
The rule doesn't only affect gains. If you sell shares at a loss to set it against other gains, then buy them back within 30 days, the loss is worked out using the buy-back price. If the price hasn't moved much, most of your loss disappears.
Legal alternatives
If you want to use your allowance but stay invested, people commonly use one of these. They're all allowed, but each has trade-offs, so check they suit you.
- Bed and ISA. Sell in your ordinary account and buy the same shares back inside a Stocks and Shares ISA. The 30-day rule doesn't apply, and future gains in the ISA are tax-free. You can put up to £20,000 a year into ISAs.
- Bed and spouse. You sell, and your husband, wife or civil partner buys the same shares. You are separate people for Capital Gains Tax, so the purchase isn't matched with your sale.
- Bed and SIPP. Buy the shares back inside a pension. This has its own rules and limits, and the money is locked away until retirement age.
- Wait 31 days before buying back, accepting that the price might move while you're out of the market.
- Buy something similar but different, such as a different fund that follows a similar market. The rule only matches the same shares, so a genuinely different investment isn't caught.
How our calculator handles it
Our calculator applies the same-day and 30-day rules automatically. Paste in all your trades, including any purchases made after a sale, and it will match them the way HMRC does. The "How the tax is calculated" section shows the matched cost for each sale.
If you need to report your gains, our step-by-step guide to the SA108 pages shows where the figures go.
Work out your own CGT
Paste your trades from your broker and see your gain, allowance and tax in seconds.
Open the calculator →Sources on GOV.UK: HS284 Shares and Capital Gains Tax, Selling shares in the same company, Capital Gains Tax allowances. Last checked 23 September 2026.
This is an estimate, not financial or tax advice. It may contain mistakes and does not cover every situation, so check your figures with HMRC or a qualified adviser before you rely on them.