A tax swap is a trade in which an investor sells a security that has fallen below its cost to realise a capital loss and at the same time buys a similar, but not identical, security to keep roughly the same market exposure. The term is used mainly for bonds, where many issues have close substitutes. The realised loss can offset capital gains, and unused amounts can be carried forward as a tax loss carryforward.
When rates rise, many bonds trade below cost. Selling one municipal bond and buying another with a different issuer, coupon or maturity keeps similar income while booking the loss. In the United States the replacement must not be substantially identical, or the wash sale rule disallows the loss. Because the new bond is bought at a lower price, its cost basis is lower, so part of the benefit is deferral. Bond trading costs can absorb much of the gain.