Developer ToolsFree generatorPDF, Excel, Word exportChina

China Unified Social Credit Code (USCC) Validator Script Generator

Chinese companies carry an 18-character unified social credit code that doubles as business registration and tax number. Typos in a vendor master break fapiao matching, withholding and supplier screening. This tool writes a script that flags malformed codes in bulk.

Fill in

Your ERP vendor export.

Generated code
Download:

Python script

# Validate China Unified Social Credit Codes (GB 32100) in a CSV export
# Reads vendor_master_export.csv, checks column TaxRegNo, writes vendor_uscc_check.csv
import csv

CHARSET = "0123456789ABCDEFGHJKLMNPQRTUWXY"
WEIGHTS = [1, 3, 9, 27, 19, 26, 16, 17, 20, 29, 25, 13, 8, 24, 10, 30, 28]


def check_uscc(raw):
    code = (raw or "").strip().upper().replace(" ", "")
    if len(code) != 18:
        return "BAD_LENGTH"
    if any(c not in CHARSET for c in code):
        return "BAD_CHARACTER"
    total = sum(CHARSET.index(c) * w for c, w in zip(code[:17], WEIGHTS))
    check = 31 - (total % 31)
    if check == 31:
        check = 0
    return "OK" if CHARSET[check] == code[17] else "BAD_CHECK_DIGIT"


with open("vendor_master_export.csv", newline="", encoding="utf-8-sig") as src:
    reader = csv.DictReader(src)
    fields = list(reader.fieldnames or []) + ["USCC_STATUS"]
    rows = []
    for row in reader:
        row["USCC_STATUS"] = check_uscc(row.get("TaxRegNo"))
        rows.append(row)

with open("vendor_uscc_check.csv", "w", newline="", encoding="utf-8-sig") as dst:
    writer = csv.DictWriter(dst, fieldnames=fields)
    writer.writeheader()
    writer.writerows(rows)

bad = [r for r in rows if r["USCC_STATUS"] != "OK"]
print(f"Checked {len(rows)} rows, {len(bad)} need review")

How the check digit works

The code has 18 characters from a 31-character set that skips I, O, S, V and Z. Characters 1 to 17 are converted to index values, multiplied by fixed weights and summed. The check value is 31 minus the sum modulo 31, with 31 mapped to 0, and the character at that index must equal position 18.

A passing check digit only proves the code is well formed, not that the company exists or is in good standing. Verify the entity on the official national enterprise credit information system before onboarding. Test the script on a copy of your export and adjust the delimiter if your ERP does not export commas.

Vendor master clean-up

Want an optional review of your supplier master data quality, including tax IDs? We can walk through it with you.

Optional. The tool and every export work without this. No spam.

How to use the generated script

Export your vendor master to CSV, name the column that holds the tax or registration number, choose the file encoding and copy the script. Python 3 is enough, there are no third-party libraries. The script adds a USCC_STATUS column with OK, BAD_LENGTH, BAD_CHARACTER or BAD_CHECK_DIGIT. Chinese ERP exports are often GBK or GB18030, so pick the correct encoding or you will see unreadable names. Review every non-OK row against the supplier's business licence before you change master data.

Code structure and the checksum

The unified code under GB 32100 has 18 characters. The first is the registration authority department code, the second the entity type, the next six an administrative division code, then nine characters of organization code, and finally the check character. The checksum uses weights 1, 3, 9, 27, 19, 26, 16, 17, 20, 29, 25, 13, 8, 24, 10, 30 and 28 over positions 1 to 17. The script reproduces that rule exactly, so a typo in any single character is almost always caught.

  • Letters I, O, S, V and Z are not used
  • Lowercase and spaces are normalized before testing
  • Older 15-digit registration numbers will show as BAD_LENGTH

ERP and data hygiene notes

Map the tax registration field consistently. In SAP it is often a tax number field on the business partner or vendor, in Oracle a registration number on the supplier site, and in Infor or Epicor a tax or VAT ID field. Decide where the code lives, and store it uppercase without spaces. Run the script before each supplier onboarding batch and before your annual vendor review, and keep the output as evidence of data checks.

Frequently Asked Questions

Does a valid check digit mean the supplier is real?

No. It only shows the code is well formed. A made-up code can pass if the check digit was computed correctly. Verify the supplier name and status on the official enterprise credit system and compare with the business licence.

Why is my old 15-digit number rejected?

Before the unified code system, companies had separate registration, tax and organization numbers. Most have been replaced by the 18-character code. Request the current code from the supplier and update your master data.

Can I run this on Excel files directly?

The script reads CSV. Save your Excel sheet as CSV first, choosing UTF-8 if available. If characters look wrong, try gbk or gb18030 as the encoding option and regenerate the script.

Is anything uploaded when I generate the script?

No. The script is built in your browser from the values you type, and it runs on your own machine against your own file. No supplier data is sent to this site.

If you need vendor master validation against ERP tables directly, Netray can help build read-only checks that run inside your environment.