# Brazil NF-e XML to Excel, CSV & JSON Converter (`dados-abertos-br/nfe-planilha`) Actor

Convert Brazilian NF-e and NFC-e XML files (layout 4.00) into a spreadsheet: one row per item with invoice header, NCM, CFOP, quantities, prices and ICMS, IPI, PIS and COFINS. Export to Excel, CSV or JSON. Buyer CPF masked by default. Reads your XML only, no SEFAZ login.

- **URL**: https://apify.com/dados-abertos-br/nfe-planilha.md
- **Developed by:** [Dados Abertos BR](https://apify.com/dados-abertos-br) (community)
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $5.00 / 1,000 results

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

**Brazil NF-e XML to Excel** turns Brazilian electronic invoice XML files, NF-e (model 55) and NFC-e (model 65), layout 4.00, into a clean spreadsheet: one row per invoice item, with the invoice header repeated on each row, so filters and pivot tables work right away. Export to Excel, CSV or JSON. It only reads the XML you provide: no SEFAZ query, no digital certificate, no login.

*Converte XML de NF-e e NFC-e em planilha Excel: uma linha por item, com NCM, CFOP e impostos.*

### What can you do with it?

- **Accounting and bookkeeping.** Turn a month of invoice XML files into one spreadsheet for review.
- **Purchase analysis.** Compare prices, quantities and suppliers across invoices.
- **Goods receiving.** Check the items of an incoming invoice against the purchase order.
- **Tax review.** See NCM, CFOP, ICMS, IPI, PIS and COFINS per item, side by side.
- **System integration.** Feed invoice data into an ERP, a database or an AI agent as JSON.

### What data does it return?

| Group | Fields |
| --- | --- |
| Invoice | `accessKey`, `model`, `series`, `number`, `issuedAt`, `operationNature`, `operationType`, `authorizationProtocol`, `authorizationStatus` |
| Issuer | `issuerCnpj`, `issuerName`, `issuerTradeName`, `issuerState`, `issuerCity` |
| Recipient | `recipientCnpj`, `recipientCpf` (masked by default), `recipientName`, `recipientState` |
| Item | `itemNumber`, `productCode`, `ean` (empty when "SEM GTIN"), `description`, `ncm`, `cest`, `cfop`, `unit`, `quantity`, `unitPrice`, `itemTotal`, `itemDiscount` |
| Taxes per item | `icmsCst` (CST or CSOSN), `icmsBase`, `icmsRate`, `icmsValue`, `ipiValue`, `pisValue`, `cofinsValue` |
| Invoice totals | `invoiceProductsTotal`, `invoiceDiscount`, `invoiceFreight`, `invoiceIcms`, `invoiceIpi`, `invoiceTotal` |
| Control | `source` (which file the row came from) |

With `rowPer` set to `nota`, you get one row per invoice with the invoice, issuer, recipient and totals groups, plus `itemCount`.

### How to convert NF-e XML to Excel

1. Open the Actor and go to **Input**.
2. Add your files: paste the XML contents in **XML contents**, or list links to the files in **XML file URLs**.
3. Choose **One row per**: invoice item (best for spreadsheets) or invoice.
4. Click **Start**. A run takes a few seconds.
5. Open the **Output** tab, click **Export** and choose Excel, CSV or JSON.

The Actor comes with a fictitious sample invoice in the input, so you can click Start and see the result before using your own files.

### How much does it cost?

Pay per result: **US$ 5.00 per 1,000 result rows**, plus a US$ 0.00005 start fee per run. Platform usage is not billed on top.

- One row is one invoice item. An invoice with 12 items is 12 rows, about US$ 0.06.
- 1,000 invoices with 10 items each are 10,000 rows, about US$ 50.
- With `rowPer` set to `nota`, each invoice is one row, whatever the number of items.

### Input

| Field | What it does | Default |
| --- | --- | --- |
| `xmlUrls` | Links to XML files (http or https, up to 5 MB each) | empty |
| `xmlTexts` | Raw XML contents, one string per invoice | sample invoice |
| `rowPer` | `item` (one row per product line) or `nota` (one row per invoice) | `item` |
| `maskPersonalData` | Mask the CPF and hide the name when the recipient is a person | `true` |

#### Input examples

Files by link:

```json
{
  "xmlUrls": [
    "https://example.com/invoices/35261100000000000191550010000012341000012345.xml",
    "https://example.com/invoices/35261100000000000191550010000012351000012356.xml"
  ],
  "rowPer": "item"
}
```

XML pasted as text, one row per invoice:

```json
{
  "xmlTexts": ["<nfeProc xmlns=\"http://www.portalfiscal.inf.br/nfe\" versao=\"4.00\">...</nfeProc>"],
  "rowPer": "nota"
}
```

### Output example

One row per item (shortened; the invoice here is fictitious):

```json
{
  "source": "xmlTexts[0]",
  "accessKey": "35261100000000000191550010000000011000000010",
  "model": "55",
  "series": "1",
  "number": "1",
  "issuedAt": "2026-11-10T10:00:00-03:00",
  "operationNature": "EXEMPLO FICTICIO - VENDA",
  "operationType": "saída",
  "issuerCnpj": "00000000000191",
  "issuerName": "EMPRESA EXEMPLO FICTICIA LTDA",
  "issuerState": "SP",
  "recipientCnpj": "11111111000111",
  "recipientName": "CLIENTE EXEMPLO FICTICIO SA",
  "recipientState": "RJ",
  "invoiceProductsTotal": 25.0,
  "invoiceIcms": 3.0,
  "invoiceTotal": 25.0,
  "itemNumber": 1,
  "productCode": "A1",
  "ean": null,
  "description": "PRODUTO EXEMPLO",
  "ncm": "96081000",
  "cfop": "6102",
  "unit": "UN",
  "quantity": 10.0,
  "unitPrice": 2.5,
  "itemTotal": 25.0,
  "icmsCst": "00",
  "icmsBase": 25.0,
  "icmsRate": 12.0,
  "icmsValue": 3.0
}
```

### Privacy and security

- **Buyer data is masked by default.** When the recipient is a person (CPF), the CPF comes as `***.456.789-**` and the name is hidden. Company recipients (CNPJ) are kept as they are. Turn `maskPersonalData` off only if you have a legal basis to process the buyer's personal data.
- **Your files stay in your account.** The Actor reads the XML, writes the rows to the dataset of your own run and sends nothing anywhere else.
- **Unsafe XML is refused.** Files with DOCTYPE or ENTITY declarations are rejected, and each file is limited to 5 MB.

### Errors

A bad file does not stop the run. Files that could not be read are listed in the `ERRORS` record of the run's key-value store, each with the reason, and the other files are converted normally.

### Use it with the API, Python, JavaScript and MCP

Run it and get the rows in one HTTP call:

```bash
curl -X POST "https://api.apify.com/v2/acts/dados-abertos-br~nfe-planilha/run-sync-get-dataset-items?token=YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"xmlUrls": ["https://example.com/invoice.xml"], "rowPer": "item"}'
```

Python:

```python
from apify_client import ApifyClient

client = ApifyClient("YOUR_API_TOKEN")
xml = open("invoice.xml", encoding="utf-8").read()
run = client.actor("dados-abertos-br/nfe-planilha").call(run_input={"xmlTexts": [xml]})
for row in client.dataset(run["defaultDatasetId"]).iterate_items():
    print(row["description"], row["quantity"], row["itemTotal"])
```

JavaScript:

```javascript
import { readFileSync } from 'node:fs';
import { ApifyClient } from 'apify-client';

const client = new ApifyClient({ token: 'YOUR_API_TOKEN' });
const xml = readFileSync('invoice.xml', 'utf8');
const run = await client.actor('dados-abertos-br/nfe-planilha').call({ xmlTexts: [xml] });
const { items } = await client.dataset(run.defaultDatasetId).listItems();
console.log(items);
```

AI agents can call this Actor as a tool through the Apify MCP server. The input and output are described by schemas, so an agent knows what to send and what comes back.

### Limitations

- **It reads, it does not fetch.** The Actor does not download invoices from SEFAZ by access key. You provide the XML.
- **NF-e and NFC-e only.** CT-e, MDF-e, NFS-e and event files (cancellation, correction letter) are not supported and go to the error list.
- **Layout 4.00.** The Actor was built for the current layout. Older layouts may come with empty fields.
- **No signature check.** It does not validate the digital signature or the status of the invoice at SEFAZ. The authorization fields come from the XML itself, when present.
- **One file, one invoice.** Batch files with several invoices in one XML are not split.
- This Actor is independent. It is not affiliated with SEFAZ or the Receita Federal.

### FAQ

**Do I need a digital certificate?**
No. The Actor only reads XML files you already have.

**Does it query SEFAZ?**
No. It does not connect to SEFAZ or to any other service.

**Does it support NFC-e?**
Yes. Models 55 (NF-e) and 65 (NFC-e) are supported.

**How do I get Excel instead of CSV?**
In the **Output** tab of the run, click **Export** and pick Excel. The same data is available as CSV, JSON and XML.

**Why is the CPF masked?**
To protect the buyer's personal data by default. Turn `maskPersonalData` off if you have a legal basis to process it.

**Can I process many files at once?**
Yes. Send several links in `xmlUrls` or several strings in `xmlTexts` in the same run.

**What happens with an invalid XML?**
It is skipped and listed in the `ERRORS` record with the reason. The other files are converted.

**Is my XML stored?**
The input and the result stay in the storage of your own Apify account, under your plan's retention rules. The Actor does not copy them anywhere else.

**How do I get one row per invoice?**
Set `rowPer` to `nota`.

**Which simple-tax fields are covered?**
For companies under Simples Nacional, `icmsCst` carries the CSOSN code.

### Resumo e perguntas em português

Converte o XML de NF-e e de NFC-e (leiaute 4.00) em planilha: uma linha por item, com os dados da nota em cada linha, NCM, CFOP, quantidades, preços e impostos (ICMS, IPI, PIS e COFINS). Exporte em Excel, CSV ou JSON.

- **Precisa de certificado digital?** Não. O robô só lê o XML que você envia.
- **Consulta a SEFAZ?** Não.
- **E o CPF do comprador?** Sai mascarado por padrão.
- **Quanto custa?** US$ 5 por mil linhas. Uma nota com 12 itens são 12 linhas.
- **Dá para ter uma linha por nota?** Sim: use `rowPer` igual a `nota`.

### Related Actors

- [ANVISA Brazil Medicines: Registry & CMED Prices](https://apify.com/dados-abertos-br/anvisa-medicamentos): Brazil's drug registry and CMED price ceilings by name, active ingredient, registration number or EAN.

### Your feedback

Found a problem or a missing field? Open an issue on the **Issues** tab of this Actor.

# Actor input Schema

## `xmlUrls` (type: `array`):

Public or signed URLs of NF-e / NFC-e XML files (up to 5 MB each).

## `xmlTexts` (type: `array`):

Raw XML contents, one string per invoice. Useful when calling the Actor from code or an AI agent. The prefilled XML is a FICTITIOUS example invoice, so you can try the Actor right away; replace it with your own files.

## `rowPer` (type: `string`):

Item: one row per product line, with the invoice header repeated (best for spreadsheets). Invoice: one row per invoice with totals.

## `maskPersonalData` (type: `boolean`):

When the buyer is a person (CPF), mask the CPF and hide the name. Company buyers (CNPJ) are not masked.

## Actor input object example

```json
{
  "xmlTexts": [
    "<nfeProc xmlns=\"http://www.portalfiscal.inf.br/nfe\" versao=\"4.00\"><NFe><infNFe Id=\"NFe35261100000000000191550010000000011000000010\" versao=\"4.00\"><ide><mod>55</mod><serie>1</serie><nNF>1</nNF><dhEmi>2026-11-10T10:00:00-03:00</dhEmi><natOp>EXEMPLO FICTICIO - VENDA</natOp><tpNF>1</tpNF></ide><emit><CNPJ>00000000000191</CNPJ><xNome>EMPRESA EXEMPLO FICTICIA LTDA</xNome><enderEmit><xMun>SAO PAULO</xMun><UF>SP</UF></enderEmit></emit><dest><CNPJ>11111111000111</CNPJ><xNome>CLIENTE EXEMPLO FICTICIO SA</xNome><enderDest><UF>RJ</UF></enderDest></dest><det nItem=\"1\"><prod><cProd>A1</cProd><cEAN>SEM GTIN</cEAN><xProd>PRODUTO EXEMPLO</xProd><NCM>96081000</NCM><CFOP>6102</CFOP><uCom>UN</uCom><qCom>10.0000</qCom><vUnCom>2.50</vUnCom><vProd>25.00</vProd></prod><imposto><ICMS><ICMS00><CST>00</CST><vBC>25.00</vBC><pICMS>12.00</pICMS><vICMS>3.00</vICMS></ICMS00></ICMS></imposto></det><total><ICMSTot><vProd>25.00</vProd><vICMS>3.00</vICMS><vNF>25.00</vNF></ICMSTot></total></infNFe></NFe></nfeProc>"
  ],
  "rowPer": "item",
  "maskPersonalData": true
}
```

# Actor output Schema

## `results` (type: `string`):

Dataset with one row per invoice item (or per invoice). Export as CSV or Excel.

## `errors` (type: `string`):

List of XML files that could not be read, with the reason. Missing when every file was read.

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "xmlTexts": [
        "<nfeProc xmlns=\"http://www.portalfiscal.inf.br/nfe\" versao=\"4.00\"><NFe><infNFe Id=\"NFe35261100000000000191550010000000011000000010\" versao=\"4.00\"><ide><mod>55</mod><serie>1</serie><nNF>1</nNF><dhEmi>2026-11-10T10:00:00-03:00</dhEmi><natOp>EXEMPLO FICTICIO - VENDA</natOp><tpNF>1</tpNF></ide><emit><CNPJ>00000000000191</CNPJ><xNome>EMPRESA EXEMPLO FICTICIA LTDA</xNome><enderEmit><xMun>SAO PAULO</xMun><UF>SP</UF></enderEmit></emit><dest><CNPJ>11111111000111</CNPJ><xNome>CLIENTE EXEMPLO FICTICIO SA</xNome><enderDest><UF>RJ</UF></enderDest></dest><det nItem=\"1\"><prod><cProd>A1</cProd><cEAN>SEM GTIN</cEAN><xProd>PRODUTO EXEMPLO</xProd><NCM>96081000</NCM><CFOP>6102</CFOP><uCom>UN</uCom><qCom>10.0000</qCom><vUnCom>2.50</vUnCom><vProd>25.00</vProd></prod><imposto><ICMS><ICMS00><CST>00</CST><vBC>25.00</vBC><pICMS>12.00</pICMS><vICMS>3.00</vICMS></ICMS00></ICMS></imposto></det><total><ICMSTot><vProd>25.00</vProd><vICMS>3.00</vICMS><vNF>25.00</vNF></ICMSTot></total></infNFe></NFe></nfeProc>"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("dados-abertos-br/nfe-planilha").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = { "xmlTexts": ["<nfeProc xmlns=\"http://www.portalfiscal.inf.br/nfe\" versao=\"4.00\"><NFe><infNFe Id=\"NFe35261100000000000191550010000000011000000010\" versao=\"4.00\"><ide><mod>55</mod><serie>1</serie><nNF>1</nNF><dhEmi>2026-11-10T10:00:00-03:00</dhEmi><natOp>EXEMPLO FICTICIO - VENDA</natOp><tpNF>1</tpNF></ide><emit><CNPJ>00000000000191</CNPJ><xNome>EMPRESA EXEMPLO FICTICIA LTDA</xNome><enderEmit><xMun>SAO PAULO</xMun><UF>SP</UF></enderEmit></emit><dest><CNPJ>11111111000111</CNPJ><xNome>CLIENTE EXEMPLO FICTICIO SA</xNome><enderDest><UF>RJ</UF></enderDest></dest><det nItem=\"1\"><prod><cProd>A1</cProd><cEAN>SEM GTIN</cEAN><xProd>PRODUTO EXEMPLO</xProd><NCM>96081000</NCM><CFOP>6102</CFOP><uCom>UN</uCom><qCom>10.0000</qCom><vUnCom>2.50</vUnCom><vProd>25.00</vProd></prod><imposto><ICMS><ICMS00><CST>00</CST><vBC>25.00</vBC><pICMS>12.00</pICMS><vICMS>3.00</vICMS></ICMS00></ICMS></imposto></det><total><ICMSTot><vProd>25.00</vProd><vICMS>3.00</vICMS><vNF>25.00</vNF></ICMSTot></total></infNFe></NFe></nfeProc>"] }

# Run the Actor and wait for it to finish
run = client.actor("dados-abertos-br/nfe-planilha").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "xmlTexts": [
    "<nfeProc xmlns=\\"http://www.portalfiscal.inf.br/nfe\\" versao=\\"4.00\\"><NFe><infNFe Id=\\"NFe35261100000000000191550010000000011000000010\\" versao=\\"4.00\\"><ide><mod>55</mod><serie>1</serie><nNF>1</nNF><dhEmi>2026-11-10T10:00:00-03:00</dhEmi><natOp>EXEMPLO FICTICIO - VENDA</natOp><tpNF>1</tpNF></ide><emit><CNPJ>00000000000191</CNPJ><xNome>EMPRESA EXEMPLO FICTICIA LTDA</xNome><enderEmit><xMun>SAO PAULO</xMun><UF>SP</UF></enderEmit></emit><dest><CNPJ>11111111000111</CNPJ><xNome>CLIENTE EXEMPLO FICTICIO SA</xNome><enderDest><UF>RJ</UF></enderDest></dest><det nItem=\\"1\\"><prod><cProd>A1</cProd><cEAN>SEM GTIN</cEAN><xProd>PRODUTO EXEMPLO</xProd><NCM>96081000</NCM><CFOP>6102</CFOP><uCom>UN</uCom><qCom>10.0000</qCom><vUnCom>2.50</vUnCom><vProd>25.00</vProd></prod><imposto><ICMS><ICMS00><CST>00</CST><vBC>25.00</vBC><pICMS>12.00</pICMS><vICMS>3.00</vICMS></ICMS00></ICMS></imposto></det><total><ICMSTot><vProd>25.00</vProd><vICMS>3.00</vICMS><vNF>25.00</vNF></ICMSTot></total></infNFe></NFe></nfeProc>"
  ]
}' |
apify call dados-abertos-br/nfe-planilha --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,dados-abertos-br/nfe-planilha"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/d8xBACHhXG1SLvTog/builds/r7t6nRuGDSZCT8EX8/openapi.json
