{"id":21711276,"url":"https://github.com/davidix/mrz-lib","last_synced_at":"2026-07-15T20:03:34.179Z","repository":{"id":77109004,"uuid":"524198054","full_name":"davidix/mrz-lib","owner":"davidix","description":"Python MRZ library,Machine Readable Zone generator and checker for official travel documents sizes 1, 2, 3, MRVA and MRVB (Passports, Visas, national id cards and other travel documents)","archived":false,"fork":false,"pushed_at":"2022-08-16T11:12:10.000Z","size":9569,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-25T16:42:27.373Z","etag":null,"topics":["mrz","mrz-codes","python"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/davidix.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-08-12T19:09:19.000Z","updated_at":"2023-02-19T19:29:37.000Z","dependencies_parsed_at":"2023-02-28T16:16:29.383Z","dependency_job_id":null,"html_url":"https://github.com/davidix/mrz-lib","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davidix%2Fmrz-lib","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davidix%2Fmrz-lib/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davidix%2Fmrz-lib/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davidix%2Fmrz-lib/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/davidix","download_url":"https://codeload.github.com/davidix/mrz-lib/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244666585,"owners_count":20490287,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["mrz","mrz-codes","python"],"created_at":"2024-11-25T23:20:54.826Z","updated_at":"2025-10-17T00:58:58.564Z","avatar_url":"https://github.com/davidix.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# MRZ Generator \u0026 MRZ Checker\n\n# this repo cloned from : https://github.com/Arg0s1080/mrz\n\n## Description:\nMachine Readable Zone generator and checker for official travel documents sizes 1, 2, 3, MRVA and MRVB (Passports, Visas, national id cards and other travel documents)\n\n\nMRZ Generator and MRZ Checker are built according to International Civil Aviation Organization specifications (ICAO 9303):\n\n* [Specifications Common to all Machine Readable Travel Documents (MRTDs)](https://www.icao.int/publications/Documents/9303_p3_cons_en.pdf)\n* [Specifications for Machine Readable Passports (MRPs)](https://www.icao.int/publications/Documents/9303_p4_cons_en.pdf)\n* [Specifications for TD1 Size Machine Readable Official Travel Documents (MROTDs)](https://www.icao.int/publications/Documents/9303_p5_cons_en.pdf)\n* [Specifications for TD2 Size Machine Readable Official Travel Documents (MROTDs)](https://www.icao.int/publications/Documents/9303_p6_cons_en.pdf)\n* [Specifications for Machine Readable Visas (MRV)](https://www.icao.int/publications/Documents/9303_p7_cons_en.pdf)\n\n\n\n\n## Usage Generator:\n#### TD1's (id cards):\n\n    Params:                      Case insensitive\n\n        document_type    (str):  The first letter shall be 'I', 'A' or 'C'\n        country_code     (str):  3 letters code (ISO 3166-1) or country name (in English)\n        document_number  (str):  Document number\n        birth_date       (str):  YYMMDD\n        sex              (str):  Genre. Male: 'M', Female: 'F' or Undefined: 'X', \"\u003c\" or \"\"\n        expiry_date      (str):  YYMMDD\n        nationality      (str):  3 letters code (ISO 3166-1) or country name (in English)\n        surname          (str):  Holder primary identifier(s). This field will be transliterated\n        given_names      (str):  Holder secondary identifier(s). This field will be transliterated\n        optional_data1   (str):  Optional personal data at the discretion of the issuing State.\n                                 Non-mandatory field. Empty string by default\n        optional_data2   (str):  Optional personal data at the discretion of the issuing State.\n                                 Non-mandatory field. Empty string by default\n        transliteration (dict):  Transliteration dictionary for non-ascii chars. Latin based by default\n        force           (bool):  Disables checks for country, nationality and document_type fields.\n                                 Allows to use 3-letter-codes not included in the countries dictionary\n                                 and to use document_type codes without restrictions.\n                                 \n#### TD2\n\n    Params:                      Case insensitive\n\n        document_type    (str):  The first letter shall be 'I', 'A' or 'C'\n        country_code     (str):  3 letters code (ISO 3166-1) or country name (in English)\n        surname          (str):  Holder primary identifier(s). This field will be transliterated.\n        given_names      (str):  Holder secondary identifier(s). This field will be transliterated.\n        document_number  (str):  Document number.\n        nationality      (str):  3 letters code (ISO 3166-1) or country name\n        birth_date       (str):  YYMMDD\n        sex              (str):  Genre. Male: 'M', Female: 'F' or Undefined: 'X', \"\u003c\" or \"\"\n        expiry_date      (str):  YYMMDD\n        optional_data    (str):  Optional personal data at the discretion of the issuing State.\n                                 Non-mandatory field. Empty string by default\n        transliteration (dict):  Transliteration dictionary for non-ascii chars. Latin based by default\n        force           (bool):  Disables checks for country, nationality and document_type fields.\n                                 Allows to use 3-letter-codes not included in the countries dictionary\n                                 and to use document_type codes without restrictions.\n                                 \n#### TD3 (Passports)\n\n    Params:                      Case insensitive\n\n        document_type    (str):  Normally 'P' for passport\n        country_code     (str):  3 letters code (ISO 3166-1) or country name (in English)\n        surname          (str):  Primary identifier(s)\n        given_names      (str):  Secondary identifier(s)\n        document_number  (str):  Document number\n        nationality      (str):  3 letters code (ISO 3166-1) or country name\n        birth_date       (str):  YYMMDD\n        sex              (str):  Genre. Male: 'M', Female: 'F' or Undefined: 'X', \"\u003c\" or \"\"\n        expiry_date      (str):  YYMMDD\n        optional data    (str):  Personal number. In some countries non-mandatory field. Empty string by default\n        transliteration (dict):  Transliteration dictionary for non-ascii chars. Latin based by default\n        force           (bool):  Disables checks for country, nationality and document_type fields.\n                                 Allows to use 3-letter-codes not included in the countries dictionary\n                                 and to use document_type codes without restrictions.\n                                 \n#### MRVA (Visas type A)\n\n    Params:                      Case insensitive\n    \n        document_type    (str):  The First letter must be 'V'\n        country_code     (str):  3 letters code (ISO 3166-1) or country name (in English)\n        surname          (str):  Primary identifier(s)\n        given_names      (str):  Secondary identifier(s)\n        document_number  (str):  Document number\n        nationality      (str):  3 letters code (ISO 3166-1) or country name\n        birth_date       (str):  YYMMDD\n        sex              (str):  Genre. Male: 'M', Female: 'F' or Undefined: 'X', \"\u003c\" or \"\"\n        expiry_date      (str):  YYMMDD\n        optional_data    (str):  Optional personal data at the discretion of the issuing State.\n                                 Non-mandatory field. Empty string by default.\n        transliteration (dict):  Transliteration dictionary for non-ascii chars. Latin based by default\n        force           (bool):  Disables checks for country, nationality and document_type fields.\n                                 Allows to use 3-letter-codes not included in the countries dictionary\n                                 and to use document_type codes without restrictions.\n                          \n#### MRVB (Visas type B)\n\n    Params:                      Case insensitive\n    \n        document_type    (str):  The First letter must be 'V'\n        country_code     (str):  3 letters code (ISO 3166-1) or country name (in English)\n        surname          (str):  Primary identifier(s)\n        given_names      (str):  Secondary identifier(s)\n        document_number  (str):  Document number\n        nationality      (str):  3 letters code (ISO 3166-1) or country name\n        birth_date       (str):  YYMMDD\n        sex              (str):  Genre. Male: 'M', Female: 'F' or Undefined: 'X', \"\u003c\" or \"\"\n        expiry_date      (str):  YYMMDD\n        optional_data    (str):  Optional personal data at the discretion of the issuing State.\n                                 Non-mandatory field. Empty string by default.\n        transliteration (dict):  Transliteration dictionary for non-ascii chars. Latin based by default\n        force           (bool):  Disables checks for country, nationality and document_type fields.\n                                 Allows to use 3-letter-codes not included in the countries dictionary\n                                 and to use document_type codes without restrictions.\n                                 \n\n##### TD3CodeGenerator -\u003e str: \n\n```python\nfrom mrz.generator.td3 import TD3CodeGenerator\n\ncode = TD3CodeGenerator(\"P\", \"UTO\", \"Eriksson\", \"Anna María\", \"L898902C3\", \"UTO\", \"740812\", \"F\", \"120415\",\"ZE184226B\")\n\nprint(code)\n```\n    \n\n##### Output:\n    P\u003cUTOERIKSSON\u003c\u003cANNA\u003cMARIA\u003c\u003c\u003c\u003c\u003c\u003c\u003c\u003c\u003c\u003c\u003c\u003c\u003c\u003c\u003c\u003c\u003c\u003c\u003c\n    L898902C36UTO7408122F1204159ZE184226B\u003c\u003c\u003c\u003c\u003c10\n\n###### Note: See other uses in [mrz.generator examples folder](https://github.com/davidix/mrz-lib/tree/master/examples/mrz_generator_samples)\n\n## Usage Checker:\n#### TD1's (id cards):\n\n    Params:\n\n        mrz_string        (str):  MRZ string of TD1. Must be 90 uppercase characters long (3 lines)\n        check_expiry     (bool):  If it's set to True, it is verified and reported as warning that the\n                                  document is not expired and that expiry_date is not greater than 10 years\n        compute_warnings (bool):  If it's set True, warnings compute as False\n\n#### TD2:\n\n    Params:\n\n        mrz_string        (str):  MRZ string of TD2. Must be 72 characters long (uppercase) (2 lines)\n        check_expiry     (bool):  If it's set to True, it is verified and reported as warning that the\n                                  document is not expired and that expiry_date is not greater than 10 years\n        compute_warnings (bool):  If it's set True, warnings compute as False\n        \n#### TD3 (Passports):\n\n    Params:\n\n        mrz_string        (str):  MRZ string of TD3. Must be 88 characters long (uppercase) (2 lines)\n        check_expiry     (bool):  If it's set to True, it is verified and reported as warning that the\n                                  document is not expired and that expiry_date is not greater than 10 years\n        compute_warnings (bool):  If it's set True, warnings compute as False\n        \n#### MRVA:\n\n    Params:\n\n        mrz_string        (str):  MRZ string of Visas type A. Must be 88 characters long (uppercase) (2 lines)\n        check_expiry     (bool):  If it's set to True, it is verified and reported as warning that the\n                                  document is not expired and that expiry_date is not greater than 10 years\n        compute_warnings (bool):  If it's set True, warnings compute as False\n        \n#### MRVB:\n\n    Params:\n\n        mrz_string        (str):  MRZ string of Visas type B. Must be 72 characters long (uppercase) (2 lines)\n        check_expiry     (bool):  If it's set to True, it is verified and reported as warning that the\n                                  document is not expired and that expiry_date is not greater than 10 years\n        compute_warnings (bool):  If it's set True, warnings compute as False\n        \n##### Id Card Checker example\n\n##### TD1CodeChecker -\u003e bool\n```python\nfrom mrz.checker.td1 import TD1CodeChecker\n    \ncheck = TD1CodeChecker(\"I\u003cSWE59000002\u003c8198703142391\u003c\u003c\u003c\\n\"\n                       \"8703145M1701027SWE\u003c\u003c\u003c\u003c\u003c\u003c\u003c\u003c\u003c\u003c\u003c8\\n\"\n                       \"SPECIMEN\u003c\u003cSVEN\u003c\u003c\u003c\u003c\u003c\u003c\u003c\u003c\u003c\u003c\u003c\u003c\u003c\u003c\u003c\u003c\")\nresult = bool(check)\nprint(result)\n```\n\n##### Output\n    True\n\n###### Note: See other uses in [mrz.checker examples folder](https://github.com/davidix/mrz-lib/tree/master/examples/mrz_checker_samples)\n\n\n##### Fields extraction example (valid for td1, td2, td3 and visas)\n```python\nfrom mrz.checker.td1 import TD1CodeChecker, get_country\n\ntd1_check = TD1CodeChecker(\"IDLIEID98754015\u003c\u003c\u003c\u003c\u003c\u003c\u003c\u003c\u003c\u003c\u003c\u003c\u003c\u003c\u003c\\n\"\n                           \"8205122M1906224LIE\u003c\u003c\u003c\u003c\u003c\u003c\u003c\u003c\u003c\u003c\u003c6\\n\"\n                           \"OSPELT\u003cBECK\u003c\u003cMARISA\u003c\u003c\u003c\u003c\u003c\u003c\u003c\u003c\u003c\u003c\u003c\")\n\nfields = td1_check.fields()\n\nprint(fields.name, fields.surname)\nprint(get_country(fields.country))\n\n```\n\n##### Output\n```\nMARISA OSPELT BECK\nLiechtenstein\n```\n###### Note: See other uses in [mrz.checker examples folder](https://github.com/davidix/mrz-lib/tree/master/examples/mrz_checker_samples) and [this issue](https://github.com/davidix/mrz-lib/issues/6)\n\n\n## Installation:\n\n#### From [Pypi repo](https://pypi.org/project/mrz/) (It may not be the latest version):\n    pip install mrz \n    \n#### Cloning this repo (It may not work fine):\n```\ngit clone https://github.com/davidix/mrz-lib.git\ncd mrz\nsudo python3 setup.py install\n```\n\n## Features:\n- [x] Transliteration of special Latin characters (acutes, tildes, diaeresis, graves, circumflex, etc)\n- [x] Arabic chars transliteration\n- [x] Several variations of Cyrillic added: Serbian, Macedonian, Belarusian, Ukrainian and Bulgarian\n- [x] Transliteration of modern Greek (experimental)\n- [x] Transliteration of modern Hebrew (without vowels) (experimental)\n- [x] Generation of the country code from its name in English (Ex.: \"Netherlands\" -\u003e \"NLD\")\n- [x] Name truncation detection\n- [x] Error report, warnings report and full report in Checker.\n- [x] Possibility that warnings compute as errors using compute_warnings keyword in Checker.\n- [x] Possibility of disabling checks for country code, nationality and type of document, allowing to use 3-letter-codes not included in the countries dictionary and to use document_type codes without restrictions in Generator.\n- [x] Added new checks for periods of time in Checker.\n- [x] Visas support\n- [x] Fields extraction in checker (name, surname, country, sex, etc) (version 0.5.0)\n\n\n###### TODO:\n- [ ] Automatic name truncation in Generator\n- [ ] Possibility of disabling checks for country code, nationality, type of document and the others fields in Checker.\n- [ ] Add logging\n\n### IMPORTANT:\n\n- MRZ is a Python module to be used as library in other programs. So, its intended audience are developers. \n**MRZ will never have a user interface nor will have CLI support.** (Of course.. if someone wants, can do it)\nHowever, **if someone is curious and wants to generate or check the mrz code of a passport or ID card, \ncan modify any of the [examples](https://github.com/davidix/mrz-lib/tree/master/examples)**.\n\n- Right now I am very busy and have very little free time. Please, before creating an issue or consulting by email, \nread [this issue](https://github.com/davidix/mrz-lib/issues/31)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdavidix%2Fmrz-lib","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdavidix%2Fmrz-lib","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdavidix%2Fmrz-lib/lists"}