Guide · Brazil

How to download and load the CNPJ database (Receita Federal open data).

Where the monthly files are now, what each of the 37 files holds, a DuckDB load that does not lose rows, and the eleven pitfalls we hit rebuilding Brazil's company register every month.

open datarelease 2026-10DuckDB

The Receita Federal publishes the full CNPJ register every month as open data: every company and branch in Brazil, active or not, with address, status, activity codes and registered contact. It is free and needs no login. It is also 7.8 GB of zipped, headerless, Latin-1 CSV in 37 files, with a few traps that silently corrupt a naive load. This guide is what we learned rebuilding it every month.

Where to download it

The files moved in 2026: the old dadosabertos.rfb.gov.br/CNPJ/ directory no longer answers, and the releases now live in a public share on the Receita's file server, one folder per month (2026-06 … 2026-10):

https://arquivos.receitafederal.gov.br/index.php/s/YggdBLfdninEJX9

The same share answers WebDAV, which is how to script it: list a month with PROPFIND and fetch each zip with resumable Range requests.

curl -X PROPFIND -H "Depth: 1" \
  "https://arquivos.receitafederal.gov.br/public.php/dav/files/YggdBLfdninEJX9/2026-10/"

curl -C - -O \
  "https://arquivos.receitafederal.gov.br/public.php/dav/files/YggdBLfdninEJX9/2026-10/Empresas1.zip"

The 2026-10 release was published on 2026-10-13 with data as of 2026-10-10. Folder listing as read on 2026-11-10:

FilePartsZippedLevelWhat it holds
Estabelecimentos0-9.zip105,417 MBestablishment level, one row per CNPJroot, order, check digits, head-office flag, trade name, status and its date and reason, foreign city and country, opening date, main CNAE, secondary CNAEs, address (type, street, number, complement, district, postcode, state, municipality code), two phones and a fax with area codes, e-mail, special status
Empresas0-9.zip101,387 MBcompany level, one row per CNPJ rootroot, legal name, legal nature, responsible's qualification, share capital, size code, federative entity
Socios0-9.zip10695 MBpartners and administrators (QSA)names and masked CPFs of people: personal data under the LGPD
Simples.zip1311 MBtax-regime optionsSimples Nacional and MEI options with dates
Cnaes.zip122 kBlookupCNAE subclass code and Portuguese label
Municipios.zip143 kBlookupReceita municipality code and name (not the IBGE code)
Naturezas.zip12 kBlookuplegal nature code and label
Motivos.zip11 kBlookupreason for the registration status
Paises.zip13 kBlookupcountry code and name
Qualificacoes.zip11 kBlookupqualification of partners and representatives

The 37 files of the 2026-10 release, 7.8 GB zipped in total.

How big it is once loaded

The 2026-10 release holds 73,809,379 establishment rows and 70,517,438 company rows. Only 28,380,653 establishments are active; removing individual entrepreneurs and other natural persons leaves 10,933,117. In Parquet with zstd, our cleaned, English-labelled active set takes 703 MB in 28 files (one per state).

Loading it with DuckDB

DuckDB reads the CSVs directly and is the fastest way we know to go from zip to a queryable table on a laptop. Establishments first:

-- unzip first, then rename: Estabelecimentos1.zip holds a file named like K3241.K03200Y1.D61010.ESTABELE
CREATE TABLE estab AS
SELECT * FROM read_csv('Estabelecimentos*.csv',
    delim=';', header=false, quote='"', escape='"',
    encoding='latin-1', all_varchar=true, auto_detect=false,
    columns={'cnpj_basico':'VARCHAR','cnpj_ordem':'VARCHAR','cnpj_dv':'VARCHAR',
             'matriz_filial':'VARCHAR','nome_fantasia':'VARCHAR','situacao':'VARCHAR',
             'data_situacao':'VARCHAR','motivo_situacao':'VARCHAR','cidade_exterior':'VARCHAR',
             'pais':'VARCHAR','data_inicio':'VARCHAR','cnae_principal':'VARCHAR',
             'cnae_secundaria':'VARCHAR','tipo_logradouro':'VARCHAR','logradouro':'VARCHAR',
             'numero':'VARCHAR','complemento':'VARCHAR','bairro':'VARCHAR','cep':'VARCHAR',
             'uf':'VARCHAR','municipio':'VARCHAR','ddd1':'VARCHAR','tel1':'VARCHAR',
             'ddd2':'VARCHAR','tel2':'VARCHAR','ddd_fax':'VARCHAR','fax':'VARCHAR',
             'email':'VARCHAR','situacao_especial':'VARCHAR','data_situacao_especial':'VARCHAR'});

-- active establishments only, with typed fields
SELECT cnpj_basico || cnpj_ordem || cnpj_dv AS cnpj,
       matriz_filial = '1'                      AS is_headquarters,
       try_strptime(data_inicio, '%Y%m%d')::DATE AS opening_date,
       cnae_principal, uf, municipio
FROM estab
WHERE situacao = '02';

Then companies, with the parallel scanner off (see the pitfalls below), joined on cnpj_basico:

CREATE TABLE emp AS
SELECT * FROM read_csv('Empresas*.csv',
    delim=';', header=false, quote='"', escape='"', encoding='latin-1',
    all_varchar=true, auto_detect=false, parallel=false,
    columns={'cnpj_basico':'VARCHAR','razao_social':'VARCHAR','natureza':'VARCHAR',
             'qualificacao_resp':'VARCHAR','capital_social':'VARCHAR','porte':'VARCHAR',
             'ente_federativo':'VARCHAR'});

-- share capital uses a decimal comma
SELECT try_cast(replace(capital_social, ',', '.') AS DOUBLE) AS share_capital_brl FROM emp;

Eleven pitfalls that corrupt a load

  1. No header row. Column names come from the Receita's layout PDF (metadados), not from the files. Declare them yourself, as above.
  2. Latin-1, not UTF-8. Read as UTF-8 and every ç, ã and é breaks. Declare encoding='latin-1' (ISO-8859-1).
  3. Quotes inside quoted fields. Embedded quotes are doubled (""). Without escape='"' a reader mis-splits the rest of the file; in our first load of a release this silently dropped more than half of the rows of one shard instead of failing.
  4. Line breaks inside fields. Quoted fields can contain newlines, so a line count is not a row count. In the October release one Estabelecimentos shard had 31,028,464 rows on 31,028,468 lines. Count with a real CSV parser.
  5. Parallel readers can split a record. DuckDB's parallel CSV scanner aborted on one Empresas shard of October 2026 with 'unterminated quote' while a single-threaded read of the same file was clean. Read the Empresas files with parallel=false; they are small enough.
  6. Odd file names inside the zips. Each zip holds one CSV with a mainframe-style name and no .csv extension: Estabelecimentos1.zip contains K3241.K03200Y1.D61010.ESTABELE, Empresas1.zip a ….EMPRECSV. Rename on extraction or glob on the suffix, or a wildcard on Estabelecimentos*.csv matches nothing.
  7. Stray control bytes. The 2026-10 release had 10 control characters inside text fields, spread over 5 shards. Strip them before writing Parquet or JSON.
  8. Dates and money are text. Dates are YYYYMMDD with 0 or blank for missing; share capital uses a decimal comma.
  9. Codes, not labels. Municipality, legal nature, status reason and CNAE are codes; join the lookup files (and note the municipality code is the Receita's own, not IBGE's).
  10. Closed companies are included. Only 38.5% of establishment rows are active. Filter situacao = '02'.
  11. People are included. 16,717,023 active establishments are individual entrepreneurs, and the Socios files list people. If you work under the LGPD or the GDPR, decide what you keep before you load it.

After loading: what still needs doing

A loaded register is not yet a company list. It still needs: the head office separated from branches; individual entrepreneurs and masked rows removed; English labels for 1,359 CNAE subclasses and the legal natures (our CNAE table is free); the accountant's phone and e-mail, which thousands of companies share, told apart from the company's own; and the corporate website, which the register does not have. That is the work the LatSouth build does every month.

Related guides

Or start from the cleaned build.

10,933,117 active Brazilian companies from the Receita Federal (CNPJ registry), cleaned, in English, with ISIC codes and no personal data. Free 25-row sample; full country file or ready-made packages.