# CFDI 4.0 XML Skeleton Generator

> Source: https://netray.co/tools/cfdi-4-0-xml-skeleton-generator
> Publisher: Netray (netray.co), AI and integration engineering for ERP and manufacturing systems.
> Section: Free Tools

## Short answer

Fill in a form and get a CFDI 4.0 XML skeleton with the right nodes and attributes, ready to adapt for test stamping with a PAC.

## Category

developer

## Region

Mexico

## Audience

- Integration developer
- ERP consultant
- Technical analyst

## Tool

**Kind:** template

**Output:** code

**Language:** xml

**Fields:**

#### Serie

**Key:** serie

**Type:** text

**Default:** A

#### Folio

**Key:** folio

**Type:** text

**Default:** 1042

#### Fecha (ISO date and time)

**Key:** fecha

**Type:** text

**Default:** 2026-10-20T10:30:00

#### MetodoPago

**Key:** metodo

**Type:** select

**Options:**

- PUE
- PPD

**Default:** PUE

#### FormaPago (99 if PPD)

**Key:** forma

**Type:** text

**Default:** 03

#### LugarExpedicion postal code

**Key:** cp

**Type:** text

**Default:** 66600

#### Issuer RFC

**Key:** emisor_rfc

**Type:** text

**Default:** EKU9003173C9

#### Issuer legal name

**Key:** emisor_nombre

**Type:** text

**Default:** ESCUELA KEMPER URGATE

#### Issuer regime code

**Key:** emisor_regimen

**Type:** text

**Default:** 601

#### Receiver RFC

**Key:** receptor_rfc

**Type:** text

**Default:** URE180429TM6

#### Receiver legal name

**Key:** receptor_nombre

**Type:** text

**Default:** UNIVERSIDAD ROBOTICA ESPANOLA

#### Receiver fiscal postal code

**Key:** receptor_cp

**Type:** text

**Default:** 86991

#### Receiver regime code

**Key:** receptor_regimen

**Type:** text

**Default:** 601

#### UsoCFDI

**Key:** uso

**Type:** text

**Default:** G03

#### ClaveProdServ

**Key:** clave_prod

**Type:** text

**Default:** 25174700

#### ClaveUnidad

**Key:** clave_unidad

**Type:** text

**Default:** H87

#### Concept description

**Key:** descripcion

**Type:** text

**Default:** Aluminum machined housing

#### Quantity

**Key:** cantidad

**Type:** text

**Default:** 100

#### Unit value

**Key:** valor_unitario

**Type:** text

**Default:** 100.00

#### Line amount (quantity x unit value)

**Key:** importe

**Type:** text

**Default:** 10000.00

#### IVA amount (16%)

**Key:** iva

**Type:** text

**Default:** 1600.00

#### Total

**Key:** total

**Type:** text

**Default:** 11600.00

**Blocks:**

<?xml version="1.0" encoding="UTF-8"?>
<cfdi:Comprobante xmlns:cfdi="http://www.sat.gob.mx/cfd/4" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sat.gob.mx/cfd/4 http://www.sat.gob.mx/sitio_internet/cfd/4/cfdv40.xsd" Version="4.0" Serie="{{serie}}" Folio="{{folio}}" Fecha="{{fecha}}" FormaPago="{{forma}}" MetodoPago="{{metodo}}" NoCertificado="00001000000500000000" Certificado="" Sello="" SubTotal="{{importe}}" Moneda="MXN" Total="{{total}}" TipoDeComprobante="I" Exportacion="01" LugarExpedicion="{{cp}}">
  <cfdi:Emisor Rfc="{{emisor_rfc}}" Nombre="{{emisor_nombre}}" RegimenFiscal="{{emisor_regimen}}"/>
  <cfdi:Receptor Rfc="{{receptor_rfc}}" Nombre="{{receptor_nombre}}" DomicilioFiscalReceptor="{{receptor_cp}}" RegimenFiscalReceptor="{{receptor_regimen}}" UsoCFDI="{{uso}}"/>
  <cfdi:Conceptos>
    <cfdi:Concepto ClaveProdServ="{{clave_prod}}" Cantidad="{{cantidad}}" ClaveUnidad="{{clave_unidad}}" Descripcion="{{descripcion}}" ValorUnitario="{{valor_unitario}}" Importe="{{importe}}" ObjetoImp="02">
      <cfdi:Impuestos>
        <cfdi:Traslados>
          <cfdi:Traslado Base="{{importe}}" Impuesto="002" TipoFactor="Tasa" TasaOCuota="0.160000" Importe="{{iva}}"/>
        </cfdi:Traslados>
      </cfdi:Impuestos>
    </cfdi:Concepto>
  </cfdi:Conceptos>
  <cfdi:Impuestos TotalImpuestosTrasladados="{{iva}}">
    <cfdi:Traslados>
      <cfdi:Traslado Base="{{importe}}" Impuesto="002" TipoFactor="Tasa" TasaOCuota="0.160000" Importe="{{iva}}"/>
    </cfdi:Traslados>
  </cfdi:Impuestos>
</cfdi:Comprobante>

**Notes:** This is an unsigned skeleton for development and test stamping. Sello and Certificado are produced when you sign with your CSD, usually by your ERP or the PAC. Sample RFCs and names are SAT public test values or fictitious. Check the current schema, catalogs and your PAC rules before production. Adding complements (payment, Carta Porte, foreign trade) requires extra namespaces and nodes.

## Content

**Intro:** Developers integrating an ERP with a PAC need a clean example of a CFDI 4.0 document. This generator builds a valid-looking skeleton with the nodes in the right order, so you can adapt it for your first test stamp.

**Sections:**

#### How to use the generator

**Body:** Fill the form with the issuer, receiver and one concept, copy or download the XML, and send it to your PAC test environment through its API. For production, the ERP should build the XML from invoice data, sign it with the issuer's CSD to produce Sello and Certificado, and submit it for stamping. Use the skeleton as a reference when debugging field mappings.

#### Structure of the document

**Body:** The root Comprobante node holds version, series, folio, date, payment method and form, currency, totals, document type, export indicator and issuing postal code. Child nodes follow a fixed order: related CFDI, issuer, receiver, concepts with their own tax breakdown, summarized taxes, and then complements. Amounts are strings with the decimal precision defined by the currency.

**Bullets:**

- Emisor: RFC, name, fiscal regime
- Receptor: RFC, name, fiscal postal code, regime, CFDI use
- Concepto: product key, unit key, quantities, amounts, tax object
- Impuestos: base, tax, factor type, rate and amount

#### Rounding and totals

**Body:** SubTotal is the sum of line amounts, taxes come from the transferred tax breakdown, and Total equals subtotal plus transferred taxes minus withholdings and discounts. Rounding rules matter: the PAC validates that tax amounts match base times rate within the tolerance SAT allows, so compute tax per line with consistent rounding and sum from lines to the header.

#### Common mistakes

**Body:** Frequent causes of rejection are a receiver name not matching the registry, a regime incompatible with the CFDI use, FormaPago 99 used with a PUE method, wrong decimals on amounts, and missing ObjetoImp. Another trap is building XML by string concatenation without escaping characters such as ampersands in names; use an XML library in production.

**Cta:** If your ERP integration with a PAC is fragile, we can help review the mapping and add pre-stamp validation against these rules.

**Faq:**

#### Is this XML ready for production?

**Answer:** No. It is an unsigned skeleton. Production documents must be signed with the issuer's certificate, validated against the schema and catalogs, and stamped by a PAC.

#### Where do Sello and Certificado come from?

**Answer:** They are generated by signing the original string of the document with the private key of the issuer's CSD and including the public certificate. The ERP or the PAC normally does this step.

#### How do I add a payment or Carta Porte complement?

**Answer:** Complements are added as a Complemento node with their own namespace and schema location. They have separate required fields and document types, so build them from the SAT guide of each complement.

#### Which test RFCs can I use?

**Answer:** SAT publishes sample taxpayer RFCs and many PACs provide test credentials. The defaults here are such sample values or fictitious. Use your PAC's test data when stamping.

## Search terms

cfdi 4.0 xml example, cfdi 4.0 xml ejemplo, cfdi xml generator, cfdi 4.0 estructura xml, cfdi xml template, cfdi 4.0 comprobante nodo emisor receptor, cfdi test xml pac, sat cfdi xml sample

---
Talk to an engineer: https://netray.co/contact?intent=erp_ai | Machine catalog: https://netray.co/agent/catalog.json
