GTA 6 safe codes will let you unlock sealed loot containers in the main story, while out exploring, but also during the lucrative robbery activity, which sees you knock over gang hideouts, banks, and other cash and contraband rich businesses.
The safe codes you need in the main story or specific missions are given to you, but in order to get a safe code during a robbery or while exploring, you have two main options:
- Find the code written down on the premises
- Interrogate an employee to get it
First off, you can sometimes find the code written on something inside the store or bank, like a note on a board in the back office perhaps, or maybe a guard you've incapacitated is carrying it—press L3 and R3 to activate Focus Mode and help you find it. In the screenshot below, for instance, you can see the code to the safe in a trailer was hidden in a selection of pictures on the wall.
You can also potentially get a code in a robbery by interrogating employees. Aim your weapon at them and use the "Threaten" or "Safe Code?" prompt shown on the screen to force them to give you the information. In certain robberies, this will also force cashiers to empty the register, as in previous GTA games.
While you're committing a robbery, it's also worth investigating the environment in general for extra loot. In the Exotic Animals Front robbery in Key Lento, for example, you can find an extra hidden money stash by talking to the very chatty parrot in the cage at the centre of the yard. There are lots of ways to make money in robberies, not just opening safes.

Once you have the safe code, you'll have to enter the four-digit code to unlock it, but time is of the essence, so the faster you can get the code, the quicker you can open the safe and load the cash into your bag.
You can tell if an establishment has a safe by selecting it on your map, which will also give you some idea of the security level (low to high) and the approximate value of the goods, so you can pick a lucrative target for your next stick up. Also make sure to grab a mask if you want to stay anonymous during any crimes.

GTA 6 guide: One-stop info shop
GTA 6 cars: The garage lineup
GTA 6 characters: Your anti-hero cast
GTA 6 map: Confirmed Vice City locales
GTA 6 PC release: When's it going to happen?