In Barcelona we went to Costa Brava, a long sandy beach in Girona, to the North of Barcelona. Barcelona has several beaches inside the city, they are good but a bit more crowded.
You can take the R1 train from Catalunya every 20-30 min if you don’t have a car. R1 train stops in most beaches along from Barcelona to Blanes along the coast, so it’s easily reachable. People living in Barcelona like to escape to Costa Brava for a short trip, if they don’t want to go further or take a boat to islands. Train wasn’t bad, sometimes can be a bit crowded.