Credit default swaps (CDS) played an important role in the financial crisis of 2008. While CDS can be used to hedge risks, they can also be used for speculative purposes (as occurred during the financial crisis) and regulations have been proposed to limit such speculative use. Here, we provide the first controlled experiment analyzing the pricing of credit default swaps in a bond market subject to default risk. We further use the laboratory as a testbed to analyze CDS regulation. Our results show that the regulation achieves the goal of increasing the use of CDS for hedging purposes while reducing the use of CDS for speculation. This success does not come at the expense of lower bond IPO revenues and does not negatively affect CDS prices or bond prices in the secondary market.