The City of London came out top for safety, with Havering, Wandsworth and Ealing in third, fourth and fifth place.
The study by Confused.com took into account the number of streetlights, CCTV cameras, police and crimes in each area, as well as the average ambulance response time and the flood risk.
A consumer survey was also carried out to find out how secure people felt.
Westminster was found to be the most dangerous borough in the capital, followed by Kensington and Chelsea, Richmond-upon-Thames, Haringey and Camden.
Low crime in the area was the most important factor for respondents, with 35 per cent saying it made them feel very safe and secure.
The number of streetlights, seeing police on the streets, cleanliness and having a neighbourhood watch were also reported to help residents sleep easier.
In contrast 42 per cent of people said loitering in the streets made them feel very unsafe.
Stretched emergency services and presence of homeless people were also factors that caused locals to feel unsafe.
London as a whole was ranked the fourth safest city in the UK, after Liverpool, Coventry and Leicester, due to the high police numbers, quick ambulance response rates and low flood risk.