opentax-engine logo

opentax-engine

The deterministic tax engine for AI agents. Highest score ever recorded on TaxCalcBench (96% exact returns)

Developer ToolsAI AgentsJavaScriptAGPL-3.0 129 20Health 82
Website GitHub

What is it?

What it is

A zero‑dependency, TypeScript‑based US federal tax calculator that outputs every calculation step, cites the exact statute, and produces a verifiable proof tree.

Why it exists

To provide a transparent, provable tax engine that never guesses, supports LLM integration, and lets anyone verify results offline. It fills the gap between ad‑hoc calculators and legal certainty by encoding the law as data and offering a proof‑based API.

Who should use it

Tax software developersAI/LLM engineers building tax-aware agentsPolicy analysts and simulatorsFinancial software engineersTax professionals needing verifiable computation

Who should avoid it

Users seeking casual tax adviceDevelopers requiring a closed-source proprietary engine without a commercial licenseUsers needing state-level tax calculations (currently out of scope)

How it works

A quick walkthrough in plain English

How opentax-engine works

Step 1 of 3

You interact with it

Open opentax-engine, send a request, or connect it to your stack.

Features

Tax calculator with proof-based answers citing specific laws and assumptions
Offline verification of proofs with Merkle root validation
Support for individual, business, estate, and trust tax scenarios
CLI and browser-based tools (self-contained HTML)
Solver layer for tax policy simulation and cliff analysis
Extensible via rule data additions without code changes
Exact cent-level calculations using bigint arithmetic
Comprehensive error handling with clear codes and messages
Support for multiple tax years and filing statuses
Detailed documentation and contribution guidelines

Advantages

  • Transparency through provable, citation-backed calculations
  • High accuracy with no floating-point errors
  • Open-source with AGPL-3.0 license (commercial licenses available)
  • Extensible by adding rules as data
  • Robust error handling and user guidance
  • Solver capabilities for complex tax policy analysis
  • Browser-based tool with no dependencies
  • Independently validated against PolicyEngine
  • Detailed audit trail via Merkle proofs
  • Supports both CLI and interactive web tools

Disadvantages

  • Complexity may require technical expertise to use effectively
  • AGPL license requires sharing modifications for commercial use
  • Requires detailed input facts for accurate calculations
  • Focused on US tax only (no state or international support)
  • Solver layer depends on pre-encoded rules (gaps may exist)
  • Browser tool is a single HTML file with potential size limitations
  • Extensive documentation may be overwhelming for new users

Installation

native

pnpm install && pnpm build

FAQ

How does opentax-engine ensure its tax calculations are accurate?

The engine uses exact bigint-cents math to avoid floating-point errors and is validated against a differential harness that compares its results to PolicyEngine US. It reproduces IRS Tax Table methods exactly for values below $100,000 and uses 'golden fixtures' to assert every intermediate calculation step to the cent.

Can I verify that a tax calculation hasn't been tampered with?

Yes. Every calculation produces a proof tree that can be saved as a JSON file. You can use the `pnpm opentax verify proof.json` command to re-derive every step independently. If any byte of the proof or the underlying rule corpus is altered, the verification will fail and specify exactly what broke.

How can I use this engine with an AI agent or LLM?

You can integrate it using the Oracle pattern via MCP (Model Context Protocol) to let models call the engine as a tool, or the Guardrail pattern using `opentax check` to automatically refute incorrect tax claims made by a model. This prevents LLMs from inventing plausible but incorrect tax figures.

What happens if the engine doesn't have enough information or doesn't support a specific tax rule?

The engine never guesses. If facts are missing, it returns a `NEEDS_FACTS` error listing the required flags. If a rule for a specific date or case isn't encoded yet, it returns `NO_APPLICABLE_RULE`. It also explicitly refuses out-of-scope items like consolidated returns or state returns rather than providing a silent, incorrect answer.

Can I calculate taxes for different tax years?

Yes. By default, the engine answers based on the law in force today, but you can use the `--as-of` flag (e.g., `--as-of 2025-12-31`) to derive answers under different tax year rules, such as different standard deductions or tax brackets.

Is the engine suitable for browser-based applications?

Yes. The engine is written in pure TypeScript with zero platform dependencies. It can run entirely in a browser, as demonstrated by the included 130 KiB self-contained HTML playground which requires no server or network connection.

Loading documentation…
View on GitHub

Featured in Videos

YouTube tutorials and walkthroughs for opentax-engine

Alternatives

Similar projects ranked by category, topics, and text overlap.

Compare
opentax-engine | MushyBook