This is a pure JavaScript implementation of the MRZ (Machine Readable Zone) generator for creating mock travel documents for testing purposes.
web-mrz-generator.mp4
https://yushulx.me/web-mrz-generator/
- Pure JavaScript
- Multiple Document Types: Supports TD1, TD2, TD3, MRVA, and MRVB formats
- Accurate MRZ Generation: Implements proper check digit calculations according to ICAO standards
- Visual Rendering: Generates mock document images with MRZ zones
- Random Data Generation: Creates random but valid MRZ data for testing
- Lightweight: Minimal dependencies, runs entirely in the browser
- TD3 (Passport): 2 lines × 44 characters
- TD1 (ID Card): 3 lines × 30 characters
- TD2 (ID Card): 2 lines × 36 characters
- MRVA (Visa Type A): 2 lines × 44 characters
- MRVB (Visa Type B): 2 lines × 36 characters
Simply open index.html in a modern web browser. No build process or server is required.
- Select a document type from the dropdown (Passport, ID Card, or Visa)
- Fill in the document details (or click "Random" for random data)
- Click "Generate" to create the MRZ
- The MRZ text and visual representation will be displayed
You can use the MRZ generator library programmatically:
// Generate a TD3 (Passport) MRZ
const passport = new TD3CodeGenerator(
'P', // Document type
'USA', // Country code
'SMITH', // Surname
'JOHN', // Given names
'L898902C3', // Document number
'USA', // Nationality
'740812', // Birth date (YYMMDD)
'M', // Sex
'120415', // Expiry date (YYMMDD)
'ZE184226B' // Optional data
);
console.log(passport.toString());
// Output:
// P<USASMITH<<JOHN<<<<<<<<<<<<<<<<<<<<<<<<<<
// L898902C3USA7408122M1204159ZE184226B<<<<<14
// Generate a TD1 (ID Card) MRZ
const idCard = new TD1CodeGenerator(
'I', // Document type
'USA', // Country code
'D23145890', // Document number
'740812', // Birth date
'M', // Sex
'120415', // Expiry date
'USA', // Nationality
'SMITH', // Surname
'JOHN', // Given names
'1234567890', // Optional data 1
'12345' // Optional data 2
);
console.log(idCard.toString());Works in all modern browsers that support:
- ES6 Classes
- Canvas API
- CSS3
MIT License