# Mexican CFDI 4.0 validator (SAT validations)

Source: https://xmlvalid.com/e-invoicing/mexico

> Check a CFDI before your PAC stamps it, or one a supplier sent you: the CFDI 4.0 schema with the Timbre Fiscal Digital and Pagos 2.0, then 163 of the validations in SAT's error matrices, from the subtotal and each line's taxes to the balances of a payment receipt, with every finding on its line and its SAT error code. Nothing is uploaded.

## E-invoicing in Mexico in short

Every invoice in Mexico is electronic. Since 1 January 2014 the CFDI (Comprobante Fiscal Digital por Internet) has been the only invoice that counts for tax purposes, for sales, services, payroll and payments alike (Código Fiscal de la Federación, articles 29 and 29-A). The issuer seals the XML with its digital seal certificate (CSD) from SAT and sends it to an authorised certification provider, a PAC, which validates it, adds the Timbre Fiscal Digital with the folio fiscal (a UUID) and passes a copy to SAT. Without that stamp the document is not a CFDI.

Version 4.0 of Anexo 20 took effect on 1 January 2022 and has been the only one accepted since 1 April 2023, when version 3.3 ended. It added the receiver's name, postal code and tax regime, which must match SAT's records, whether each line is subject to tax (ObjetoImp), the export key and the global invoice for sales to the general public. An invoice not paid when it is issued (payment method PPD) is followed by a payment receipt, a CFDI of type P with the Pagos 2.0 complement, for each payment. A CFDI is cancelled with one of four reasons, and many cancellations need the receiver's acceptance.

## How to check a CFDI

1. Open the [validator with the CFDI 4.0 profile](https://xmlvalid.com/validate?schema=cfdi-4.0). A CFDI opened or pasted picks the profile on its own, by its Comprobante element and namespace.
2. Paste the XML or drop the file, an invoice or a payment receipt, stamped or not, then press **Validate**.
3. Each finding names SAT's error code; click it for the rule, its Spanish wording from the matrix and what usually causes it.

## What is checked

First the SAT schemas: cfdv40.xsd with its catalogues, the Timbre Fiscal Digital 1.1 and the Complemento para recepción de Pagos 2.0. Then our rules, written from SAT's error matrices for CFDI 4.0 (of 25 March 2026) and Pagos 2.0 (revision B) and the validations of Anexo 20. Each rule carries SAT's error code and the Spanish description of the matrix: SubTotal is the sum of the lines ([CFDI40108](https://xmlvalid.com/rules/CFDI40108)), a line's Importe is quantity times price within the limits Anexo 20 computes from the decimals written ([CFDI40167](https://xmlvalid.com/rules/CFDI40167)), each tax is base times rate within the same limits ([CFDI40180](https://xmlvalid.com/rules/CFDI40180)), the tax summary adds up from the lines ([CFDI40221](https://xmlvalid.com/rules/CFDI40221)), and an invoice to the general public is a global invoice with its period ([CFDI40130](https://xmlvalid.com/rules/CFDI40130)). Decimals follow the currency, and the payment form and method, exchange rate, the receiver's regime and the use of the CFDI follow the catalogues.

For a payment receipt the Pagos 2.0 rules run too: the fixed fields of type P, each related document's balance after the payment ([CRP20244](https://xmlvalid.com/rules/CRP20244)), the taxes paid converted by EquivalenciaDR ([CRP20268](https://xmlvalid.com/rules/CRP20268)), the totals in pesos and the account patterns of each payment form.

What needs more than the file is not checked: the seal and certificate, SAT's RFC registry (the receiver's name, postal code and regime), limits that need the day's exchange rate, and what the product catalogue requires of each line. Other complements (Carta Porte, Nómina, Comercio Exterior) are not in the schema, so a document that carries one is reported invalid.

## Profiles to check with

- [CFDI 4.0](https://xmlvalid.com/schemas/cfdi-4.0): The Mexican electronic invoice, with the Timbre Fiscal Digital stamp and the Pagos 2.0 payment complement. [Validate](https://xmlvalid.com/validate?schema=cfdi-4.0)

## Rules invoices break most

Each one has a page with what it checks, its test and, for many, how to fix it.

- [`CFDI40108`](https://xmlvalid.com/rules/CFDI40108): El TipoDeComprobante es I,E o N, el importe registrado en el campo no es igual al redondeo de la suma de los importes de los conceptos registrados (SubTotal …,...
- [`CFDI40167`](https://xmlvalid.com/rules/CFDI40167): El valor del campo Importe no se encuentra entre el limite inferior y superior permitido (…, … × …).
- [`CFDI40180`](https://xmlvalid.com/rules/CFDI40180): El valor del campo Importe o que corresponde a Traslado no se encuentra entre el limite inferior y superior permitido (…, … × …).
- [`CFDI40221`](https://xmlvalid.com/rules/CFDI40221): El campo Importe correspondiente a Traslado no es igual al redondeo de la suma de los importes de los impuestos trasladados registrados en los conceptos donde e...
- [`CFDI40130`](https://xmlvalid.com/rules/CFDI40130): Cuando el tipo de comprobante sea Ingreso y el campo Rfc del nodo receptor corresponda al valor "XAXX010101000" y el campo Nombre del nodo Receptor contenga la...
- [`CRP20244`](https://xmlvalid.com/rules/CRP20244): El campo ImpSaldoInsoluto debe ser mayor o igual a cero y calcularse con la suma de los campos ImpSaldoAnt menos el ImpPagado (… - …, …).
- [`CRP20268`](https://xmlvalid.com/rules/CRP20268): El campo BaseP que corresponde a Traslado, no es igual a la suma de los importes de las bases registrados en los documentos relacionados donde el impuesto del d...

## Questions

### Is the invoice uploaded?

No. The schema check and the rules both run in your browser. Only the API and URL monitors validate on our servers.

### Does a valid result mean the PAC will stamp it?

It means the CFDI passes the schema and the validations of SAT's matrices that need only the file. The PAC also checks the seal and the certificate, SAT's RFC registry (name, postal code and regime of the receiver) and limits that need the day's exchange rate, so it can still refuse the document for something a file alone doesn't show.

### Can I check a stamped CFDI or a payment receipt?

Yes. The Timbre Fiscal Digital is part of the schema, though its seal is not verified, and a payment receipt (type P) gets the Pagos 2.0 rules, from the balances of each related document to the totals in pesos.

### Are these SAT's own rules?

They are our implementation of the validations SAT publishes in its error matrices, with SAT's codes and wording; PACs run their own. The examples use SAT's test RFCs.

### Can I check invoices from code?

Yes: the API and the command-line client with --schema cfdi-4.0, or --schema auto for a folder of mixed files.

### Official sources

- [SAT: Anexo 20, CFDI 4.0 standard and error matrices (in Spanish)](http://omawww.sat.gob.mx/tramitesyservicios/Paginas/anexo_20.htm)
- [SAT: CFDI 4.0 schema (cfdv40.xsd)](http://www.sat.gob.mx/sitio_internet/cfd/4/cfdv40.xsd)
- [SAT: how a CFDI is cancelled (in Spanish)](https://www.sat.gob.mx/minisitio/Factura/documentos/EsquemaCancelacionCFDI.pdf)
- [Código Fiscal de la Federación (in Spanish)](https://www.diputados.gob.mx/LeyesBiblio/pdf/CFF.pdf)

### Other countries

- [French e-invoice validator](https://xmlvalid.com/e-invoicing/france)
- [German e-invoice validator: XRechnung and ZUGFeRD](https://xmlvalid.com/e-invoicing/germany)
- [Belgian e-invoice validator: Peppol BIS](https://xmlvalid.com/e-invoicing/belgium)
- [KSeF invoice validator: FA(3)](https://xmlvalid.com/e-invoicing/poland)
- [Croatian eRačun validator](https://xmlvalid.com/e-invoicing/croatia)
- [RO e-Factura validator](https://xmlvalid.com/e-invoicing/romania)
- [FatturaPA validator](https://xmlvalid.com/e-invoicing/italy)
- [UAE e-invoice validator (PINT AE)](https://xmlvalid.com/e-invoicing/uae)
- [InvoiceNow validator (PINT SG)](https://xmlvalid.com/e-invoicing/singapore)
- [JP PINT validator](https://xmlvalid.com/e-invoicing/japan)
- [Australian e-invoice validator (PINT A-NZ)](https://xmlvalid.com/e-invoicing/australia)
- [Spanish e-invoice validator](https://xmlvalid.com/e-invoicing/spain)
- [Dutch e-invoice validator: SI-UBL 2.0 and NLCIUS](https://xmlvalid.com/e-invoicing/netherlands)
- [Danish e-invoice validator: OIOUBL 2.1](https://xmlvalid.com/e-invoicing/denmark)
- [Norwegian e-invoice validator: EHF](https://xmlvalid.com/e-invoicing/norway)
- [Swedish e-invoice validator: Peppol BIS](https://xmlvalid.com/e-invoicing/sweden)
- [Finnish e-invoice validator: Finvoice](https://xmlvalid.com/e-invoicing/finland)
- [Austrian e-invoice validator for e-Rechnung.gv.at](https://xmlvalid.com/e-invoicing/austria)
- [Czech e-invoice validator: ISDOC](https://xmlvalid.com/e-invoicing/czech-republic)
- [Portuguese e-invoice validator: CIUS-PT](https://xmlvalid.com/e-invoicing/portugal)
- [ZATCA e-invoice validator (FATOORA)](https://xmlvalid.com/e-invoicing/saudi-arabia)
- [Brazilian NF-e validator (SEFAZ rules)](https://xmlvalid.com/e-invoicing/brazil)
- [Malaysian e-invoice validator (MyInvois)](https://xmlvalid.com/e-invoicing/malaysia)
