It depends on the reason for leaving and your location. Under the Labor Contract Law, compensation is owed only in the listed cases (employer-initiated termination, layoff, etc.), not for voluntary resignation. In Shanghai the rule is stricter for foreign employees: outside the five mandatory labor standards, whatever the contract says applies, and no contract term means no compensation.
Nationwide (all cities)
The national law: Article 46 cases only
Layer one — the national law. Article 46 of the Labor Contract Law lists the situations where the employer must pay economic compensation, and Article 47 sets the amount (one month's wage per full year of service, half a month for six months to one year, etc.). Voluntary resignation by the employee is not among the Article 46 situations, so a foreigner who resigns on their own is generally not entitled to statutory economic compensation under the national law.
The geographic split
Note the geographic split: per the same case analysis, most other regions (Beijing, Guangdong, Jiangsu, Shandong, Chongqing) apply the Labor Contract Law uniformly to foreign employees, treating them like Chinese workers. So the answer differs by region — in Shanghai compensation turns on the contract, in most other regions the statutory rules apply directly.
Local variations
The Shanghai rule: follow the contract
Layer two — the Shanghai rule for foreign employees. A Shanghai Justice Bureau case analysis ((2024) Hu 0109 Min Chu 4146) states the rule directly: for foreign employees, the five mandatory labor standards are minimum wage, working hours, rest and leave, workplace safety, and social insurance; economic compensation (and the double damages for unlawful termination) fall outside these five. Outside the five standards, whatever the employment contract provides applies — the Shanghai High Court rule (Hu Gao Fa Min Yi [2006] No. 17) is 'if agreed, follow the agreement; if not agreed, no statutory benefit'. So a foreign employee in Shanghai gets compensation only if the contract promises it.