Sign inGet started
Back to blog
Tax reform

Receita Federal's IBS/CBS calculator: how it works and how to use it

The Receita Federal's open source IBS/CBS calculator computes CBS, IBS and IS under the general regime. How it works, where it fits, and what Stackin checks before sending to SEFAZ.

The Receita Federal's IBS/CBS calculator is an open source REST API, written in Java under the MIT license, that computes CBS, IBS and the Selective Tax (IS) for general-regime operations, serves the official tables used in the calculation, and generates and validates the tax groups of electronic fiscal documents. It does not issue or authorize invoices, and its declared scope is CBS, IBS and IS: ICMS appears only as an input value that makes up the calculation base.

The code was released by Portaria Cotec no. 342 of 2026-11-12, published in the Diário Oficial da União on 2026-11-13, in three public repositories of the ReceitaFederal GitHub organization. The Receita itself says the aim is not to replace the systems companies already use, and the repository roadmap is direct: the calculator does not replace DF-e authorization systems and does not, by itself, perform the assessment of the period.

What the Receita Federal published

calculadora-rtc-regime-regular (version 1.7.2, Java 25 and Spring Boot) is the general-regime engine. It calculates a whole operation, which fails on the first error, or with observability, which reports the state of each item without interrupting the others. It computes the unified calculation base for the NF-e/NFC-e and the NFS-e, generates XML from the calculation result, validates XML against the XSD, and exposes as open data the CST, cClassTrib, legal basis, NCM, NBS and reference-rate tables. XML generation covers NF-e, NFC-e, CT-e and other models; for the NFS-e, the code only validates. To run it locally you first have to generate the SQLite database with Flyway: without it, the offline profile does not start.

calculadora-rtc-simples-nacional computes CBS and IBS for Simples Nacional taxpayers. It accepts CRT 1, 2 and 3, picks the activity's annex taking the Fator R into account, and rejects the MEI (CRT 4) as out of scope. The effective rate arrives in one of two ways: in the unassisted mode you send the effective-rate row in the request body; in the assisted mode it comes from a table of effective rates fed by the PGDAS, a centralized database that the repository does not ship. The roadmap says the calculator does not compute the effective rate, which stays with the PGDAS-D.

calculadora-rtc-gerador-danfse, written in Go, generates the DANFSe PDF from the NFS-e XML, in the layout of Technical Note 008 v1.02 of 2026-07-14. The same note sets 2026-08-03 as the date the ADN's DANFSe generation API is suspended, and the generator is code you run yourself.

The calculator's scope and limits

The repositories set the scope clearly. The calculator does not authorize documents, and the DANFSe generator states that drawing the graphic representation does not replace the issuance and authorization of the NFS-e. It also does not perform the period assessment, does not calculate ICMS (which only enters as a base component and, in 2027, is still deducted from the general-regime base), does not compute the Simples effective rate and does not serve the MEI. The CST and cClassTrib come in as operation data: the calculator checks them against the official tables and against NCM/NBS, but does not choose the classification for you. Treatments not yet implemented come back with the state NAO_IMPLEMENTADO, and the roadmap lists the Manaus Free Trade Zone and cashback among the planned items.

Which rates it uses in 2026 and in 2027

For 2026, the embedded database carries reference rates of 0.9% for CBS and 0.1% for IBS (state share; the municipal share is 0%). The official examples say that, from 2027, the aliquotasNominais field is mandatory (before that, it is forbidden) and that any calculation made with supplied rates comes back as CALCULO_SIMULADO, with the x-warning-dados-simulados header giving the reason. In practice, the calculator runs the rules, but the caller supplies the 2027 rate, and the result is marked as simulated.

On the SEFAZ side, NT 2025.002-RTC v1.53 requires vIBSUF (rule UB35-10, rejection 1041), vIBSMun (UB54-10, rejection 1052) and vCBS (UB67-10, rejection 1069) to be recomputed from vBC and the rate, minus vDif and vDevTrib, accepting a tolerance of 0.01 up or down. With a reduction, the rate used is the effective one (pAliqEfet). This matters because rounding has ties: the calculator's CHANGELOG records that they go to the even digit, so a base of 25.00 at 0.9% gives vCBS 0.22, while rounding half up would give 0.23. One cent of difference fits in the tolerance; more than that is a rejection.

What Stackin does with this today

On the NF-e, the issuer sends, per item, the cst, the classification (cClassTrib) and the rates (rate_state, rate_city, rate_federal) inside ibs_cbs. Stackin does not choose the classification, which is a tax decision about the operation, and derives the amounts from the rates so that an item and the total never disagree. Stackin does not call the Receita's calculator: the API validates and builds the group.

Before sending to SEFAZ, the API checks each item against the official CST and cClassTrib tables loaded in the reference database. It refuses with a 422 a cClassTrib that belongs to another CST (IBS_CBS_CLASS_CST_MISMATCH, SEFAZ rejection 1024), a cClassTrib not in force on the issue date, in the issuer UF's timezone (IBS_CBS_CLASS_NOT_IN_FORCE), and a cClassTrib the document model does not allow (IBS_CBS_CLASS_NOT_ALLOWED, rejection 1025). The group also follows the CST: for CST 510 and 515, Stackin writes the gDif (without it, SEFAZ answers 1030), and the gIBSCBS is written only when the CST requires it. Today the API does not build the groups that CSTs 620, 800, 810 and 811 ask for, and those items remain subject to SEFAZ refusal.

Stackin's IBS/CBS calculation is tested against cases from the Receita's own calculator, run in the API's test suite. Left out are the government-procurement and regular-taxation cases, which have no equivalent input field, and the rounding tie above is a known divergence, within the SEFAZ tolerance.

On the NFS-e, the DPS IBS/CBS group carries cst, classification and operation_indicator (the cIndOp). Base, rates and reductions are refused with a 422, because the Sefin Nacional computes the amounts. In 2026 the group is optional on the NFS-e, and Stackin sends it only when the issuer supplies ibs_cbs; in production the MEI cannot send it, and in homologation, from competência 2026-10-01, every regime may.