nota-kit Docs Try demo ID GitHub

nota-kit Documentation

nota-kit is an offline JavaScript receipt OCR library that reads receipt photos on the user's device and returns structured JSON. Your app keeps full control over forms, business rules, and storage. This guide covers everything from install to server validation.

Install

  1. Install the package:
    npm install nota-kit
  2. Copy the three int8 models (det.onnx, rec.onnx, l4.onnx), label metadata (l4_meta.json), and WebAssembly runtime (~9.6 MB total) to your app's public folder:
    npx nota-kit assets public/nota-kit
    Re-run whenever you update nota-kit. Pass this folder path as base or modelsDir.
  3. Add these two headers on pages using nota-kit so WebAssembly can run multi-threaded for faster phone reads:
    Cross-Origin-Opener-Policy: same-origin
    Cross-Origin-Embedder-Policy: require-corp
    Note that third-party scripts, images, and iframes on the page must allow cross-origin embedding. Without these headers, nota-kit still works, only slower.

Usage

Pick whichever integration fits your stack. The result JSON is identical.

HTML (Laravel Blade, PHP, Django, Rails, Svelte, React, Vue...)

<script type="module">import "nota-kit/element";</script>
<nota-capture base="/nota-kit/" lang="en"></nota-capture>
<script>
  document.querySelector("nota-capture").addEventListener("nota-result", e => {
    console.log(e.detail);   // see Result below
  });
</script>

Attributes: base (path from step 2), lang (id or en), sample (optional sample image URL), upload="false" to hide the upload button, min-receipt-score (0-1, default 0.5) threshold before asking for a retake, and unstyled to use your own styling. Events: nota-result, nota-state, nota-error. Style via CSS variables (--rcp-accent, --rcp-ok, --rcp-warn, --rcp-surface) and ::part().

Browser without the web component (canvas / ImageData)

import { createNotaReader } from "nota-kit";

const reader = await createNotaReader({
  modelsDir: "/nota-kit",
  wasmPaths: "/nota-kit/ort/",
});
const res = await reader.readImage({ w, h, data });

Headless camera (custom UI)

import { createCapture, createNotaReader } from "nota-kit";

const reader = createNotaReader({ modelsDir: "/nota-kit", wasmPaths: "/nota-kit/ort/" });
const cap = createCapture({ video: videoEl, reader });
cap.subscribe(state => {
  // state.status: idle | starting | searching | adjust | hold | reading | done | error
  if (state.status === "done") console.log(state.result);
});
cap.start();

Node.js and CLI

npx nota-kit read receipt.jpg

In Node.js, createNotaReader() automatically resolves models from @nota-kit/models with no modelsDir or wasmPaths arguments required.

Result

Unreadable fields are null. Money strings keep their original printed formatting without altering thousands or decimal separators.

FieldExampleNotes
merchantTOKO NUSANTARA JAYAStore or merchant name
invoiceINV-2026-0842Receipt or invoice number
datetime27-11-2026 14:15Printed date and time
items[{"name": "BERAS PANDAN 5KG", "qty": "1", "unit_price": "75,000", "discount": null, "price": "75,000"}]Line items with qty, unit price, item discount, and line total
subtotal126,500Subtotal before discount or tax
discountnullReceipt-level discount if present
taxnullTax or service charge if printed
total126,500Grand total
paid150,000Amount paid
change23,500Change returned
perlu_dicek{"total": ["arithmetic_items_sum"]}Object mapping flagged field names to reason codes. Empty ({}) when valid.
info{"receipt_score": 1, "checks": {"items_sum": true, "subtotal_discount": null, "paid_change": true}, "ms": 2034, "versi": "0.1.0"}Arithmetic consistency score (0-1), per-check states, device read time, and version
cardJPEG BlobReceipt photo read (a JPEG Blob in <nota-capture>)

Debugging

When a field is wrong, pass { debug: true } to include debug.lines with the raw OCR lines and assigned token roles.

const r = await reader.readImage(img, { debug: true });

perlu_dicek

Fields that should be reviewed by the user, mapped to their reason codes. When all checks pass and the total is present, the object is empty ({}).

CodeFieldMeaning
missing_totaltotalGrand total could not be read or is missing.
arithmetic_items_sumtotalSum of item prices matches neither subtotal nor total.
arithmetic_subtotal_discounttotalSubtotal minus discount does not equal total.
arithmetic_paid_changechangePaid minus change does not equal total.
low_receipt_scoretotalreceipt_score is below minReceiptScore.
low_receipt_scoretotalNo text lines were detected in the image.

receipt_score and checks

receipt_score is the share of checks that returned true out of all active (non-null) checks. Three checks verify the numbers on the receipt.

CheckPasses when
items_sumSum of item prices (or net item prices) matches subtotal or total
subtotal_discountsubtotal - discount matches total
paid_changepaid - change matches total

Form example

Only render the inputs you need. As long as each input name matches a field in the result, this snippet fills them and highlights any flagged fields from perlu_dicek.

<nota-capture base="/nota-kit/"></nota-capture>
<form id="bookkeeping">
  <input name="merchant"> <input name="invoice"> <input name="total">
  <button>Save</button>
</form>
<script>
  let receipt = null;
  const form = document.getElementById("bookkeeping");
  document.querySelector("nota-capture").addEventListener("nota-result", e => {
    receipt = e.detail;
    for (const [k, v] of Object.entries(receipt)) {
      if (form.elements[k]) form.elements[k].value = v ?? "";
    }
    for (const el of form.elements) {
      if (el.name) el.classList.toggle("needs-review", Boolean(receipt.perlu_dicek[el.name]?.length));
    }
  });
</script>

Send to server

Submit the JSON data as usual. Only upload the receipt photo if your application actually needs to store an image copy.

form.addEventListener("submit", async e => {
  e.preventDefault();
  await fetch("/transactions", {
    method: "POST",
    headers: { "Content-Type": "application/json" },
    body: JSON.stringify({
      merchant: form.elements.merchant.value,
      total: form.elements.total.value,
      items: receipt?.items ?? [],
    }),
  });
});

On a Node.js server, treat submitted fields as untrusted user input. Re-run computeL5 and parseMoney to verify arithmetic consistency before saving to your database.

import { computeL5, parseMoney } from "nota-kit/l5";

app.post("/transactions", (req, res) => {
  const { items = [], ...fields } = req.body;
  const l5 = computeL5(fields, items);
  if (Object.keys(l5.perlu_dicek).length) {
    return res.status(400).json({ error: "Receipt totals need review", perlu_dicek: l5.perlu_dicek });
  }
  const totalAmount = parseMoney(fields.total);
  // save to database
});

Offline

On first run, nota-kit caches the models and runtime in the browser Cache API so receipt reading keeps working offline while the page is open. To allow full page reloads offline, register a service worker that caches your HTML, JS, and CSS (see apps/demo/sw.js).

Privacy

Photos and receipt data never leave the device unless your own app sends them. Network requests from nota-kit only fetch the models and WebAssembly runtime. Code and public models are released under Apache-2.0 and trained solely on synthetic data plus the public CORD v2 dataset (CC-BY-4.0).

FAQ

How is this different from Tesseract.js?

Tesseract.js outputs unparsed text without receipt structure. nota-kit includes line detection, a receipt-trained WebAssembly OCR model, row and role grouping, and arithmetic checks with perlu_dicek.

Is it safe for receipt privacy?

Yes. Inference runs locally in the browser via ONNX Runtime Web with zero external API calls, so your app controls what data is persisted to your server.

Can I use it with React, Vue, Next.js, or Nuxt?

Yes. The <nota-capture> web component works in plain HTML, React, Vue, Svelte, Laravel Blade, and Angular, and createNotaReader runs in Node.js and CLI.

How large is the offline download?

The int8 models and WebAssembly runtime total about 9.6 MB, fetched once and cached in the browser Cache API for offline reads.