If you have stayed in China for at least 180 days, you can apply at the exit-entry administration office. You must generally apply in person with your passport, a residence registration form, and a completed application form; the certificate is issued within about 3 working days.
Nationwide (all cities)
The 180-day threshold
Foreign nationals who have stayed in China for at least 180 days can apply for a certificate of no criminal record. The exact procedure and required documents are set by each city's public security bureau.
Timing and online options
Across cities, the certificate is generally issued within about 3 working days. In Beijing, applicants who have resided in Beijing for at least 180 days can also apply online through the Beijing Public Security Bureau's online portal (gaj.beijing.gov.cn), and collect the electronic certificate from the same portal; for cities without online service, you can call the national exit-entry hotline 12367 to ask about your city.
Local variations
Shanghai
In Shanghai, you apply in person at the exit-entry administration office. Online application is not available, and no appointment is required. Bring your original passport and the residence permits valid during the period the certificate covers, a copy of your Accommodation Registration Form for Overseas Personnel, and a completed application form for the Certificate of No Criminal Record for Foreigners (filled out on site). All materials are verified on the spot, and extra documents may be requested if anything is unclear.
Shenzhen
In Shenzhen, per the Guangming District government, you must have lived in Shenzhen continuously for more than six months. For an on-site personal application, bring your original passport, your temporary residence registration form, and a completed application form (filled out and signed on site). Note that many foreigners forget to update the residence registration form each time they renew their residence permit or change address, which fragments the residence record and can block the application.