It might surprise you if you got your image from other mediterranean cities, but Barcelona is actually one of the safest ones in Europe. Serious crime and violence are very rare. Pickpocketing in some touristy areas on the other hand is a real thing here and happens quite frequently (La Rambla, parts of Raval, at train and metro stations). In general the streets of Barcelona feel safe even late at night. That might be connected to the fact that in Spain people don't usually drink until they get kicked out of the bar.