Pepper Spray is forbidden and likely will be discovered
Pepper spray is forbidden in China. Your luggage will be searched and/or x-rayed frequently when in China, including customs controls when exiting into the airport and entering the subway or train/bus stations. There is a high chance that it will be discovered. (I've had a can of deo spray taken away when getting on a bus once. Even pocket knives get confiscated there at times.) If that happens in the best case it will be thrown away and in the worst case police will treat you as a potential terrorist. You do not want this kind of interaction with security forces.
Right to carry arms / alternative weapons
You asked for alternative means of self-defense and mentioned in a comment that you do walk around with a form of self-defense even at home. I somehow come to assume you are a US citizen, where there is a constitutional right to bear arms. Many Americans find it surprising that this is not at all the case around the globe, and the principle adhered to is rather the "monopoly on violence" owned by the state. Carrying weapons (and be it only for self-defense) in China is highly unusual and links you to crime in the eyes of the police and public. I strongly advise against it.
It has additionally been pointed out by @Berwyn that if shit hits the fan,
Chinese legal culture is much less permissive in self-defense claims
compared to e.g. the US.
As mentioned in an earlier comment, China is a fairly safe place. If you want to be extra safe, adhere to official travel warnings of your embassy/government, e.g. the Australian Smarttraveller.gov.au on China, and the "stay safe" section on Wikivoyage.
Your best self-defense is to avoid situations where you would need self-defense.
That includes, but is not limited to
- don't get wasted, even better, don't get drunk
- don't do drugs - they are illegal anyway
- avoid prostitutes or any other illegal activity
- know and avoid the scams. That includes the unofficial taxis
- avoid being alone in an area. That one is easy in China
- be wary of strangers, especially those speaking (good) English
- avoid nightclubs and bars. Intoxicated folks can get aggressive (pretty much anywhere in the world)
Finally to answer your true question, if you do still feel the urge for a form of self-defense, martial arts are perfectly legal to my knowledge.
do you think I need self defense, it is what can be used as a legal form of self defense.