Beijing feels like one of the safest places I've ever been, anywhere in the world. I can walk almost anywhere, at any hour of the day or night, and rarely feel like I need to have any concern about my physical safety (odd 'photo-opportunities' aside, of course).
There are People's Liberation Army (PLA) guards in many areas of the city, and municipal police and traffic police and security guards and just about any other type of public safety enforcement you might imagine. As a laowai (foreigner) I know that I receive special treatment, a veritable carte blanche to behave less well than the locals, to do almost anything I wish, with minimal response - providing I don't commit a felony, of coarse. I try not to abuse the privilege, other than for practicing the New York art of jaywalking.
It has been pointed out to me that the police and PLA guards are more scared of me than I am of them. They don't want to arrest a laowai. It means piles of extra paperwork. It would likely mean losing their job. And, it would also probably mean being sent out from the city to a rural village for some assignment much less pleasant than patrolling city streets.