Download
Four files, free to use in your tests and software. The file names will not change, so you can fetch them from a script.
| File | Rows | What it holds | Download |
|---|---|---|---|
| Valid VINs | 240 | 10 for each of 24 makes, across models and years 2015 to 2026. 26 of them have an X check digit | CSV · JSON |
| Invalid and edge cases | 195 | Wrong check digit (50), forbidden letters I, O, Q (40), wrong length (40), formatting problems (30), swapped neighbours (25), edge cases (10). Each row says what a strict validator should answer | CSV · JSON |
Columns
| Column | File | Meaning |
|---|---|---|
| vin | both | The VIN exactly as it should be fed to your code, including any stray spaces or quotes in the formatting rows |
| make, model, year | valid | The pattern the VIN was built from |
| wmi, plant_letter, check_digit | valid | Characters 1 to 3, character 11 and character 9 |
| category | invalid | Which kind of mistake the row tests |
| expected_valid | invalid | true or false: the answer of a strict validator that does no cleaning |
| note | invalid | What was done to the VIN |
6 rows are marked expected_valid = true even though they sit in the edge-case file, for example 11111111111111111. They pass the check digit but are not real VINs. That is the point of them: passing the math does not make a VIN real. The formatting rows are marked false because a strict validator rejects the raw text, but each becomes valid once you strip the extra characters.
What to Test With It
- Validation logic: run every row through your validator and compare with
expected_valid. - Input cleaning: the formatting rows show what real users paste: lowercase, spaces, quotes, dashes, a trailing comma.
- Error messages: each category needs its own message, such as "has 16 characters" or "contains the letter O".
- Bulk import: load the 240 valid VINs into a spreadsheet or database table and check nothing is rejected.
- The X check digit: 26 valid rows have an X in position 9. Code that only expects digits fails on these.
Code That Uses It
Both samples validate a VIN and then check it against the files. We ran them against these exact files: 240 of 240 valid rows pass, and all 195 invalid and edge-case rows give the expected answer. Put the sample next to the files and run it.
JavaScript (Node 18 or newer)
// Validate a VIN: 17 characters, no I, O or Q, and a matching check digit.
const VALUES = { A: 1, B: 2, C: 3, D: 4, E: 5, F: 6, G: 7, H: 8, J: 1, K: 2, L: 3, M: 4, N: 5, P: 7, R: 9, S: 2, T: 3, U: 4, V: 5, W: 6, X: 7, Y: 8, Z: 9 };
const WEIGHTS = [8, 7, 6, 5, 4, 3, 2, 10, 0, 9, 8, 7, 6, 5, 4, 3, 2];
function isValidVin(vin) {
if (!/^[A-HJ-NPR-Z0-9]{17}$/.test(vin)) return false;
let sum = 0;
for (let i = 0; i < 17; i++) {
const ch = vin[i];
sum += (/\d/.test(ch) ? Number(ch) : VALUES[ch]) * WEIGHTS[i];
}
const check = sum % 11 === 10 ? 'X' : String(sum % 11);
return vin[8] === check;
}
// Run it against the test files (Node 18 or newer).
const valid = require('./vin-test-valid.json');
const cases = require('./vin-test-invalid.json');
console.log('valid file:', valid.filter(v => isValidVin(v.vin)).length, 'of', valid.length, 'pass');
const wrong = cases.filter(c => isValidVin(c.vin) !== c.expected_valid);
console.log('invalid file:', cases.length - wrong.length, 'of', cases.length, 'give the expected answer');
Python 3
import csv
VALUES = {**{c: i for i, c in enumerate("ABCDEFGH", 1)}, **{c: i for i, c in enumerate("JKLMN", 1)},
"P": 7, "R": 9, **{c: i for i, c in enumerate("STUVWXYZ", 2)}}
WEIGHTS = [8, 7, 6, 5, 4, 3, 2, 10, 0, 9, 8, 7, 6, 5, 4, 3, 2]
ALLOWED = set("ABCDEFGHJKLMNPRSTUVWXYZ0123456789")
def is_valid_vin(vin: str) -> bool:
"""17 characters, no I, O or Q, and a matching check digit."""
if len(vin) != 17 or not set(vin) <= ALLOWED:
return False
total = sum((int(c) if c.isdigit() else VALUES[c]) * w for c, w in zip(vin, WEIGHTS))
check = "X" if total % 11 == 10 else str(total % 11)
return vin[8] == check
# Run it against the CSV files.
with open("vin-test-valid.csv", newline="", encoding="utf-8-sig") as f:
rows = list(csv.DictReader(f))
print("valid file:", sum(is_valid_vin(r["vin"]) for r in rows), "of", len(rows), "pass")
with open("vin-test-invalid.csv", newline="", encoding="utf-8-sig") as f:
rows = list(csv.DictReader(f))
right = sum(is_valid_vin(r["vin"]) == (r["expected_valid"] == "true") for r in rows)
print("invalid file:", right, "of", len(rows), "give the expected answer")
How We Built and Checked It
A script builds the files from the make and model patterns behind our VIN generator by make and model, with a fixed random seed so the result is repeatable. A second script then runs every row through the same validator code that powers our bulk VIN validator. All rows agree. More on our methods is on the How We Test page.
More Test Material
- We Tested 100 VINs: Which Pass Validation and Why?, with a 100-case CSV and the results.
- How to Generate Test VINs for Software Testing
- How to Validate a VIN in Code
- How Do I Find Duplicate VINs in a Spreadsheet or List?, with a 290-row sample file that has 42 planted duplicates.
- Bulk VIN Generator for fresh random VINs, and the VIN Validator and Check Digit Calculator to inspect one.
Found a problem in a file, or want another kind of test data? Tell us on the contact page.