This was originally my response to a question on Quora but the topic is very suitable here. Under normal conditions, it is quite safe for a foreigner to travel in China. However I will remind you that, as the car manufacturers say, your mileage may vary.
I am an American who has lived in China since 2004. I have lived in three large cities – Zhengzhou, Guangzhou, and Chongqing – and have visited many more cities and places (Beijing, Shanghai, Shenzhen, Haikou, et al.) I have traveled by train, plane, bus, and car. I have walked the streets late at night – avoiding obvious trouble spots, of course – and felt completely safe.
The first reason is the almost complete absence of firearms among private citizens. I did not say there is no crime, only no guns. My point is that you are extremely unlikely to encounter a robber armed with a gun. Indeed, because of the omnipresent construction, I am told that it is easier to get your hands on some dynamite than a handgun. But when was the last time you heard of anyone attempting an armed robbery with dynamite?
The second reason is that, even in the largest, most international cities like Beijing or Shanghai, foreigners are still a rare commodity. Most Chinese have a high regard for foreign countries, especially America. You are much more likely to encounter myriad shy approaches from people who ask you friendly questions, than anyone with bad intent. Even if you encounter a bad guy, they will probably think twice before accosting you. They know that robbing foreigners can generate lots of unwanted attention, something criminals try to avoid.
Related to that is the third reason. Because of their appearance, foreigners are highly visible. Wherever you go, you can be sure that many eyes are on you, even if they don’t actually make eye contact. On a city bus, you will probably be the only foreigner. In a restaurant, you are likely to be given a prominent table so the public can see that foreigners patronize that establishment. This visibility helps keeps you safe because it would take a very bold pickpocket or robber to try anything while everyone in the area is watching the intended victim. However, the status of being a foreigner won’t protect your possessions.