Skip to content
Radar CNPJ
Credit

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.

Updated

1Open Apps Script

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

2Paste 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]];
}

3Use it in the sheet

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