Skip to main content

Extract data from Brazilian NF-e electronic invoices

A Brazilian NF-e is authorised before the goods leave the yard. Cleared by the state tax authority (SEFAZ) under layout 4.00, the Nota Fiscal Eletronica works on a clearance model: the issuer transmits the invoice, SEFAZ validates it and returns an authorisation protocol, and only then can the shipment move under the DANFE, the printed representation that carries the barcode. One identifier ties it all together, the chave de acesso, the 44-digit access key that encodes the issuer state, the period, the CNPJ, the model, the series, and the invoice number, and is what any party uses to validate the NF-e at SEFAZ. Every NF-e names the issuer and recipient by CNPJ (the 14-digit taxpayer number) and Inscricao Estadual (the state registration), the issuer regime tributario (CRT), and on every line the Brazilian tax codes that decide how the goods are taxed. Line-level tax codes are the substance of an NF-e. Each product carries an NCM code, the eight-digit Mercosur tariff classification, a CFOP code, the four-digit operation code that says what kind of movement the line is and which taxes apply, and often a CEST code for tax substitution. ICMS dominates, the state value-added tax, and it is levied por dentro, meaning it is calculated inside the price rather than added on top, so a line shows an ICMS base, a rate, and an ICMS amount already embedded in the goods value. Invoice totals cover the products total, any freight and discount, the total ICMS, and an approximate total of all taxes required by the transparency law Lei 12.741. Two document models exist: the standard NF-e (55) and the consumer NFC-e (65). Talonic reads the authorised NF-e, whether the DANFE or the source PDF, into a structured record that keeps the access key and every tax code. An NF-e numbered 4571, series 001, from Industria Paulista de Componentes Ltda. (CNPJ 12.345.678/0001-90) to Comercial Recife Ltda., under access key 35260612345678000190550010000045711123456789, returns its two product lines, 4,800.00 BRL of ICMS at 12% embedded in a products total of 40,000.00 BRL, and an invoice total of 40,000.00 BRL that a Brazilian fiscal system posts.

What gets extracted from Brazilian NF-e electronic invoices

Chave de Acesso3526061234567800019055001000004571112345678944-digit access key, chNFe
Document Model5555 NF-e, 65 consumer NFC-e
Issuer CNPJ12.345.678/0001-90
Issuer Inscricao Estadual110.042.490.114
Regime Tributario (CRT)31 Simples Nacional, 3 Regime Normal
Operation NatureVENDA DE MERCADORIA
Line ItemsArray: NCM, CFOP, CEST, quantity, unit price, ICMS base, rate, amount
ICMS Total4,800.00 BRLState VAT, vICMS
Products Total40,000.00 BRLvProd
CurrencyBRL
Invoice Total40,000.00 BRLvNF

How extraction works for Brazilian NF-e electronic invoices

In practice an NF-e reaches a fiscal team as the DANFE printed representation, the source PDF, or a portal export, and the access key and Brazilian tax codes still have to be recovered. Talonic classifies the document and binds every value to the NF-e layout 4.00 field set held in the Field Registry, so the 44-digit chave de acesso, the document number and series, the model and layout version, and the issuer and recipient CNPJ and Inscricao Estadual resolve regardless of layout. Each line keeps its NCM tariff code, its CFOP operation code, its CEST code where present, its quantity and unit price, and its ICMS base, rate, and amount, while the issuer regime tributario (CRT) and the buyer IE indicator are typed. Products total, freight, discount, total ICMS, and the Lei 12.741 approximate taxes are read, and because ICMS is levied inside the price the extraction keeps the embedded amount rather than adding it to the total. Per-value confidence and a pixel-region pointer under DIN SPEC 91491 let a fiscal analyst verify an access key or an NCM code against the source. The extraction structures what the authorised NF-e states and does not compute the tax owed or re-validate the SEFAZ authorisation.

Sample extraction

An authorised NF-e (model 55) with two product lines carrying ICMS

{
  "access_key": "35260612345678000190550010000045711123456789",
  "document_number": "4571",
  "document_series": "001",
  "document_date": "2026-06-12",
  "document_model": "55",
  "layout_version": "4.00",
  "operation_nature": "VENDA DE MERCADORIA",
  "operation_direction": "1",
  "issue_purpose": "1",
  "environment_type": "1",
  "issuer_state_code": "35",
  "supplier.name": "Industria Paulista de Componentes Ltda.",
  "supplier.tax_id": "12.345.678/0001-90",
  "supplier.state_registration": "110.042.490.114",
  "supplier.tax_regime": "3",
  "buyer.name": "Comercial Recife Ltda.",
  "buyer.tax_id": "98.765.432/0001-10",
  "buyer.ie_indicator": "1",
  "products_total_amount": 40000,
  "discount_amount": 0,
  "freight_amount": 0,
  "tax_base_amount": 40000,
  "tax_amount": 4800,
  "total_approx_taxes": 6800,
  "freight_modality": "9",
  "payment_method": "15",
  "total_amount": 40000,
  "line_items": [
    {
      "product_code": "PC-1001",
      "barcode_gtin": "7891234560017",
      "product_description": "Placa de circuito impresso",
      "ncm_code": "85340011",
      "cfop_code": "6101",
      "unit": "UN",
      "quantity": 200,
      "unit_price": 145,
      "line_amount": 29000,
      "icms_base_amount": 29000,
      "icms_tax_rate": 12,
      "icms_tax_amount": 3480
    },
    {
      "product_code": "PC-1002",
      "barcode_gtin": "7891234560024",
      "product_description": "Conector industrial",
      "ncm_code": "85366990",
      "cfop_code": "6101",
      "unit": "UN",
      "quantity": 500,
      "unit_price": 22,
      "line_amount": 11000,
      "icms_base_amount": 11000,
      "icms_tax_rate": 12,
      "icms_tax_amount": 1320
    }
  ]
}

Frequently asked

What is the chave de acesso, and does the extractor read it?

It is the 44-digit access key that encodes the issuer state, period, CNPJ, model, series, and number, and is used to validate and track the NF-e at SEFAZ. It is captured whole, along with the document model (55 for NF-e, 65 for the consumer NFC-e) and the layout version.

Which Brazilian tax codes come out per line?

Each line keeps its NCM tariff classification (eight digits), its CFOP operation code (four digits), its CEST code where present, and its ICMS base, rate, and amount, so a fiscal system reads how each product is taxed rather than a single description.

How is ICMS handled in the totals?

ICMS is the Brazilian state VAT and is levied inside the price (por dentro), so the extraction keeps the ICMS amount embedded in the goods value rather than adding it on top. The products total, ICMS base, total ICMS, and the Lei 12.741 approximate taxes are read as stated, and the line ICMS is checked to foot to the total.

Does it re-validate the SEFAZ authorisation or compute the tax owed?

No. Talonic structures what the authorised NF-e states and links each value to its place on the document. Re-validating the authorisation at SEFAZ and determining the tax owed are outside the extraction.

Ready to extract from your own Brazilian NF-e electronic invoices?

Author note

Reviewed by Talonic engineering · last reviewed 2026-07-07