Currencies that are pegged or fixed require that foreign currencies are held by the central issuer at a proportional amount. This is analogous to having a portfolio of currencies that the central bank issues shares from - in the form of its own currency.
We will continue with this analogy, if the central bank says these "shares" are worth $1, but the underlying components of the portfolio are worth $0.80 and decreasing, then it is expensive for the central bank to maintain its peg, and eventually they will have to disregard the peg as people start questioning the central bank's solvency. (People will know the $1 they hold is not really worth what the central bank says it is, because of the price changes people experience in buying goods and services, especially when it comes to imports. Shadow economies will also trade using a currency more reflective of labor, which happens no matter what the government's punishments are for doing so).
Swiss National Bank (central bank) did this in early 2015, as it experienced volatility in the Euro which it had previously been trying to keep it's currency pegged to. It became too expensive for it to keep this peg on its own.
The central bank can devalue its currency by adjusting the proportions of the reserve, such as selling a lot of foreign currency X, buying more of currency Y. They can and do take losses doing this. (Swiss National Bank is maintaining a large loss)
They can also flood their economy with more of their currency, diluting the value of each individual 1 dollar equivalent. This is done by issuing bonds or monetizing goods and services from the private sector in exchange for bonds. People colloquially call this "printing money" but it is a misnomer in this day and age where printers are not relevant tools. The good and service goes onto the central bank's balance book, and the company/entity that provided the service now has a bond on its book which can be immediately sold to someone else for cash (another reading is that the bond is as good as cash). The bond didn't previously exist until the central bank said it did, and central banks can infinitely exchange goods and services for bonds.
Bond monetization (also called Quantitative Easing) is practiced by the Federal Reserve in the United States, Bank of Japan, European Central Bank and now the Central Bank of the Republic of China