Piran has no airport of its own. The nearest is Trieste–Friuli Venezia Giulia (about an hour's drive across the Italian border), followed by Ljubljana (two hours) and Pula in Croatia (an hour and a half). All three see regular budget flights from across Europe.
There is no direct rail service. The standard route is to take a train to Koper, the regional centre half an hour up the coast, and then a local bus (line 1 or 1B) the rest of the way; both arrive at the small bus station outside the town walls, since cars are not permitted in the centre. Buses also run direct from Ljubljana three times a day, taking around two and a half hours.
Driving is the easiest option but parking is genuinely difficult: leave the car at the large Fornace garage outside the walls and take the free shuttle bus into Tartini Square.