If you’re traveling abroad, it’s inevitable that you’re going to have to exchange currency to pay for things in the destination country. But exchanging currency isn’t free.

There are two costs to look out for when exchanging your money for foreign currency: foreign transaction fees and exchange rates. Both affect how much you end up paying for the exchange. Foreign transaction fees are fees charged for making payments abroad and converting currency.

Exchange rate refers to how much foreign currency you get in exchange for your home currency. For example, if the exchange rate for converting US Dollars to Euros is 0.97, that means you’ll get €0.97 for every $1 you exchange. However, this rate can vary depending on where you make the exchange — if the rate is lower, that means you’ll get less currency in return.

Here are the best ways to exchange currency and avoid hefty transaction fees.

Before traveling

It’s generally best to exchange currency before you travel. There’s a simple reason why: You can do it at your bank or credit union.

Not only is it a safe and familiar option, but banks and credit unions also tend to offer the best exchange rates. You may still be charged a conversion fee, but the cost of exchanging currency will be much less overall than it would be for other options.

If you’re in the planning stages of a trip, make a travel budget, accounting for transportation, food and entertainment costs. Then, you can estimate how much cash you’ll need for the trip and stop by your local bank or credit union branch to get the cash ahead of time.

Some alternatives for exchanging currency in your home country include online currency converters and money exchange kiosks, but these often charge high fees and offer subpar exchange rates.

During the trip

When you land in a foreign country, a place to exchange currency might be one of the first things you look for, if you haven’t exchanged it ahead of time. But use discretion before handing your money over to a potential tourist trap.

Airport kiosks and tourist centers where you can exchange currency offer very low exchange rates, or they’ll come with high foreign transaction fees.

The better option is to look for an ATM. Some banks have in-network or affiliate ATMs in other countries, so you can avoid paying out-of-network fees. Furthermore, there are even financial institutions that reimburse you for ATM fees worldwide, including LendingClub and Charles Schwab.

While it can be good to take out larger sums of cash from an ATM at once rather than pay for multiple small withdrawals, also consider financial safety. If you’re carrying a large amount of cash around and it gets lost or stolen, it can’t be replaced.

One way to avoid the risk of carrying cash is to use a credit card whenever possible. With a credit card comes fraud protection. You may also be able to earn travel rewards for purchases, or even avoid foreign transaction fees with a no-foreign-transaction-fee card.

After coming back from a trip

When your trip is finished, you may have foreign currency left over. There are a couple of options for what you can do to exchange it back into your home currency.

Again, sticking to your bank or credit union is usually the most reliable option for getting the best rate. Not all financial institutions will buy back foreign currency, though.

Currency exchange stores or airport kiosks are another way to exchange your leftover money. It won’t be at a premium rate, but you’ll still get some money back, rather than being stuck with unused cash.

What are the best alternatives to exchanging cash?

When it’s possible, use a no-foreign-transaction-fee credit card. The credit card issuer will typically offer better exchange rates than many other options, and you’ll avoid having to pay a fee of up to 3 percent for foreign transactions. Note that not all credit card types are accepted in all countries — Visa and Mastercard tend to be the most accepted worldwide.

Similarly, there are debit cards that come with no foreign transaction fees. Paying for things directly with a debit card means you can avoid ATM fees while also getting better exchange rates. Even if the debit card does charge a conversion fee, this charge will likely be lower than the fee charged for a typical credit card.

Bottom line

The options for exchanging currency include banks and credit unions, ATMs, kiosks and conversion stores. It’s best to avoid currency exchange kiosks and stores as much as possible, since they often charge high fees and have poor exchange rates.

The best thing you can do for exchanging currency at a good rate is to plan ahead. Then, you can take out foreign currency in advance at your bank or credit union at a decent rate and with a lower transaction fee. But remember that carrying cash comes with a risk, so it’s important to also have a debit or credit card option for making purchases abroad.