Officers from the drugs squad carried out the raids over three weeks in December in Cardiff Bay and Grangetown as part of a larger push to drive out dealers.
It follows a similar operation, revealed by the Echo on Tuesday, in which 35 dealers from Roath, Cathays and Splott were put behind bars for almost 100 years.
The men arrested in the latest drive, Operation Versailles, range from user-dealers to more organised criminals and are all charged with supplying class A drugs, including heroin and crack cocaine.
Of the 24 arrested, 19 were remanded into custody by the court and five have been bailed.
A 38-year-old and a 22-year-old from Jamaica and a 19-year-old from Zimbabwe all face being deported if they are found guilty.
Three other men were charged as part of the previous operation, Operation Michigan.
Officers involved included the neighbourhood policing teams of Grangetown and Cardiff Bay, roads policing, operational support teams, CID and the dog section.
Detective Chief Inspector Andrew Davies of South Wales Police said: “Operation Versailles is about putting drug dealers in prison, deterring London-based dealers from coming to Cardiff, reducing crime, and, more importantly, giving the streets back to the community.
“Acting on information from the community and our own intelligence, we identified a number of individuals involved in the supply of heroin and crack cocaine in Grangetown. In a series of pre-planned intelligence-led operations we have arrested the majority of these individuals.
“Although crime is down in these areas, we know Grangetown and Cardiff Bay have issues with anti-social behaviour, robbery and car crime and there is no doubt that this is linked to drug-dealing activity. I hope this will improve the quality of life for residents who I wish to thank for their ongoing support and co-operation.
“Operation Versailles should also be a warning to anyone thinking of coming to Cardiff to deal drugs. Don’t do it – you will be caught.”
As part of the operation, northern areas of Grangetown were cleaned up by Community Payback gangs and Cardiff council. Graffiti, litter and broken glass were removed in an attempt to reduce anti-social behaviour but local residents called for the “Charles and Diana” graffiti, on Wedmore Road, to be saved.
Grangetown councillor Asghar Ali said: “Drug-related crime is the biggest problem in Grangetown and I’m glad these kind of people have been caught and charged. I think the community will heave a big sigh of relief.”