# Look up CNPJ records in Google Sheets with Radar CNPJ

A sheet function brings the company name and status of each CNPJ, with no paid add-on.

Radar CNPJ · Updated 2026-10-14

## Step 1. Open Apps Script

In the sheet, open Extensions, Apps Script, and delete the sample code.

## Step 2. Paste the function

Paste the function and save.

```
/**
 * Razão social e situação de um CNPJ, pelo Radar CNPJ. Uso: =RADAR_CNPJ(A2)
 * @customfunction
 */
function RADAR_CNPJ(cnpj) {
  const limpo = String(cnpj).replace(/[^0-9A-Za-z]/g, "").toUpperCase();
  const resposta = UrlFetchApp.fetch('https://radar-cnpj.com/api/cnpj/' + limpo, { muteHttpExceptions: true });
  if (resposta.getResponseCode() !== 200) return "HTTP " + resposta.getResponseCode();
  const empresa = JSON.parse(resposta.getContentText()).data;
  return [[empresa.razaoSocial, empresa.situacao.label]];
}
```

## Step 3. Use it in the sheet

Type =RADAR_CNPJ(A2) next to the CNPJ. The first time, allow internet access.

[Open a record](https://radar-cnpj.com/en/?cnpj=00000000000191)

[Look up CNPJ records in Google Sheets with Radar CNPJ](https://radar-cnpj.com/en/guias/google-sheets)
