How do I digitize years of paper service tickets, invoices or receipts? PickBits Paper-to-Records takes photos or scans, asks your own AI to read them, and produces validated CSV plus a review queue for anything uncertain.
It handles one document or a folder. It hashes source files to skip exact duplicates in that intake, groups pages explicitly, normalizes images when ffmpeg is available, validates against your schema, and resumes completed work. It does not merge records across years, dedupe business records, or import into your software. Those steps belong to a separate migration workflow.
Install Node 22 or newer. This project has zero runtime dependencies. From the project folder:
node bin/paper-to-records.mjs doctor
node bin/paper-to-records.mjs init --template service-ticket
npm run demoOpen examples/lawn-care-tickets/out/out.csv and review.csv. Six phone-photo-style carbon-copy tickets become six rows, with three in review: a crossed-out time, an unreadable ZIP, and an overwritten date. Yellow and pink pads have red ticket numbers, handwritten service ticks, blue or black ink, a margin phone, a crease and slight blur. Mesa, Gilbert and Chandler are real cities; people and street addresses are invented, and phones use the reserved 555-0100–0199 range. Replay uses local canned responses and makes no network calls. The checked-in CSV files and per-document out/_raw/ JSON are exactly what the CLI generates.
Run the extraction yourself:
node bin/paper-to-records.mjs extract examples/lawn-care-tickets/tickets --schema examples/lawn-care-tickets/schema.json --via replay --replies examples/lawn-care-tickets/replies --out examples/lawn-care-tickets/out/out.csvThe installed command is paper-to-records; the source command above works without installing. Add --excel for a UTF-8 BOM. CSV cells that start with formula characters are prefixed with an apostrophe. Import date-like identifiers, ZIPs and phone numbers as text in your spreadsheet to preserve their formatting.
Start with init --template service-ticket, invoice, or receipt. It creates schema.json and refuses to overwrite an existing file. --out my-schema.json selects another name. Edit the fields to match your forms:
{
"name": "My tickets",
"description": "One completed job per document",
"fields": [
{ "name": "customer", "type": "string", "required": true },
{ "name": "service_date", "type": "date", "required": true },
{ "name": "amount", "type": "number", "required": true, "min": 0 },
{ "name": "paid", "type": "boolean", "required": true },
{ "name": "reference", "type": "string", "required": false }
],
"rules": [{ "requiredIf": { "field": "paid", "equals": true, "required": ["reference"] } }],
"hints": ["Leave unreadable values null. Never infer a date convention."]
}Field names start with a lowercase letter and contain letters, digits and underscores. Names ending in _confidence are reserved. Types are string, number, integer, date, time, enum, boolean, and list. Enums and checkbox lists need an enum array of unique string choices. Optional settings are required, pattern, numeric min/max, a one-based page, and hint. gte: [a, b] requires a to be at least b when both are present; use comparable numeric, date, or time fields. requiredIf names a trigger field, an exact equals value, and a required array. JSON types must match: true differs from "true".
One loader generates the prompt, strict JSON Schema, validation functions, and CSV columns. The AI returns { "customer": { "value": "Example", "confidence": "high" }, ... }. Every property is required in the AI output; unavailable values use null, with confidence unknown. Confidence can be high, medium, low, or unknown. CSV interleaves each field and its confidence, followed by _flags, _source, and _parse. Nullable JSON values become empty CSV cells. Lists use a JSON array inside the CSV cell, preserving labels that contain spaces.
The service-ticket template sets preserveRaw: true, dateOrder: "MDY" and yearHint: 2025. Change these for your records; DMY is also supported. Each model cell must also contain raw, the as-written text or null. Deterministic code derives values from that text before validation, ignoring model guesses about normalized values. Dates become real calendar dates in YYYY-MM-DD, between 1900 and 2100. Missing years use yearHint; two-digit years use its century. Without a year hint, 4-12 and 4/11/25 stay unresolved; without an order, non-ISO numeric dates stay unresolved. Hints cannot resolve unreadable digits.
Times become HH:MM: 10:50a becomes 10:50, 1:15 PM becomes 13:15, and unsuffixed 9:00 means 09:00. Comparisons are same-day. Amount fields use normalize: "amount" to turn $72, 72.00 or $110 — into numbers. normalize: "phone" accepts ten US national digits and outputs E.164; other lengths are null with pattern_mismatch, with canonical +1 E.164 accepted on repeat normalization. CSV formula protection prefixes a literal apostrophe to the leading plus; spreadsheet imports should treat phones as text.
Checkbox list fields transcribe every choice into raw, e.g. [x] Mow; [ ] Edge; ...; only ticked choices enter services, in schema order. normalize: "paid" turns a Paid tick or pd cash into true and an explicitly empty Paid box into false. Optional paidMethod uses normalize: "paidMethod" and the same explicit payment notation to extract cash/check/card. A tick alone supplies no method. Validators enforce these canonical types and formats and compare any available raw text with the derived value. Schemas without preserveRaw keep the original two-property output contract. Regexes and configuration are user-controlled; only load schemas you trust.
Your images go to the provider you pick. Review its retention and privacy settings before sending private documents. This tool has no hosted service, telemetry, automatic upload, runtime packages, or network calls in replay mode. Normalized images, JSON results, and failed raw replies stay in <out.csv>.work. Keep that folder and the CSVs private. The CLI disables session persistence, but cannot control upstream provider logging or installed CLI configuration.
Claude: sign in with a Claude subscription using claude auth login, then:
node bin/paper-to-records.mjs extract my-tickets --schema schema.json --via claude --out out.csvIt checks claude auth status --json for authMethod claude.ai, grants only Read, uses dontAsk, and stores image copies under each run's working directory. Both ANTHROPIC_API_KEY and ANTHROPIC_AUTH_TOKEN are removed from the child environment. If either is present, extraction refuses unless you explicitly pass --allow-api-key. That override relaxes the login guard; it still strips the keys. A successful Claude result must declare success and end_turn; update your CLI if it omits those markers.
Codex: sign in using codex login with ChatGPT. Replace --via claude with --via codex. It checks the ChatGPT login, uses ephemeral execution with a read-only sandbox, attaches each image, and sends the prompt on stdin. It strips OPENAI_API_KEY and refuses a set key without --allow-api-key. The override permits other stored CLI login methods; it still strips the environment key. A successful process exit and final-message file are required.
API: explicitly opt in with your own key in OPENAI_API_KEY. Use --via api --api-base <your HTTPS API base> --model <model> --input-rate <USD per million input tokens> --output-rate <USD per million output tokens>. The base should include the provider's API version prefix. It appends chat/completions, sends base64 images, and requires native strict JSON structured output support. The first run prints a per-document estimate and refuses to call without --yes. Supply rates from your provider; image costs vary, and the estimate is not a spending cap. A repair adds a second call. No automatic retries are made for quota errors.
Replay: --via replay --replies replies reads <source-stem>.txt, and <source-stem>.repair.txt if needed. --via replay replies also works. Reply stems must be unique across your input folders. Use this for reproducible demos and tests.
JPEG, PNG, WebP, HEIC and PDF are supported. ffmpeg fixes metadata rotation and scales the long edge to at most 2000 pixels; change this with --max-edge. Without ffmpeg, supported raster images are copied with a warning; HEIC requires a build that can decode it. PDFs require pdftoppm or magick with PDF support. doctor reports missing converters and subscription logins, and warns about billing keys without showing their values. Converter presence does not guarantee a particular codec is supported.
By default, each source image is one document; all pages of a PDF are one document. --pages N groups N source files in sorted relative-path order, with the final group allowed to be shorter. --folders groups files by their containing folder. Use one folder per document, with page numbers in filenames. These modes are mutually exclusive. Exact duplicate source bytes are skipped within the input. --limit N limits document groups, and --concurrency N defaults to two, with a maximum of 32. Hidden folders, symlinks and generated .work folders are skipped. Output and review filenames must end in .csv.
out.csv contains every completed document. review.csv is the subset needing attention. Flags are required_missing, pattern_mismatch, out_of_range, enum_unknown, date_implausible, rule_failed, and low_confidence, each naming a field or rule. Any confidence below high or any flag sends the row to review. Invalid output gets one repair attempt. If both fail, the row has parse_failed, empty values, and raw replies in its work sidecar. _parse records direct, fenced, object, repaired, or parse_failed.
Compare each review row to its source image. Fix values and confidence only when the image or an authoritative record supports the change. Keep unresolved fields empty. Review flags are generated evidence; after correcting a working CSV copy, check it with:
node bin/paper-to-records.mjs validate corrected.csv --schema schema.jsonValidation recomputes field and rule flags, rather than trusting old _flags. It exits 1 while rows still need review, and 0 when they pass. A malformed CSV or mismatched header also fails. Extraction exits 2 on quota and 1 on other errors. On quota, the affected document gets no completed record or CSV row; earlier completed records remain available. Rerun the same command to resume. Atomic .part renames protect completed JSON. An output lock rejects simultaneous runs; after a crashed process, remove its run.lock only once that process has ended. Move the work folder aside to retry finished records, including parse failures. Changed source bytes, schema, transport, model, or image size get different result keys. Do not edit an input while extraction is running.
out.meta.json holds counts, schema hash, transport and the generator identity. With preserveRaw, _raw/<source-stem>-<content-key>.json beside the CSV holds one document's _raw fields, source filenames and parse path, including repaired transcriptions. The content key avoids collisions for equal stems and grouped documents. Compare these files with the photos and normalized CSV; unreadable text retains visible digits and ? markers. Successful result cells also retain raw in the work folder, and resume recreates the public raw sidecars without a provider call. Keep both locations private with real records. The CSV body contains only data, with no stamp row. Editing a CSV does not change cached results: rerunning extraction regenerates it from sidecars. Keep corrections in a separate working copy.
npm test
npm run preflight
npm run fixturesTests run offline and keep scratch files inside this repository. Preflight also scans for leaks (allowing only reserved fictional phone numbers) and installs a locally packed tarball into a local consumer with lifecycle scripts disabled. Only npm run fixtures, the developer script, fetches the free Google Fonts Caveat and Kalam on a cache miss; their fonts and OFL notices are included with the example. It uses an installed Chrome/Chromium/Edge, or FIXTURE_BROWSER, with profiles and caches inside this repository and browser network resolution disabled. Seeded per-word baseline, rotation, size and opacity variation plus perspective, textured surfaces and shadows produce the six images. It fails clearly if rendering or font fetching is unavailable. npm run demo uses the checked-in images and replies offline. There are no runtime dependencies. See DEMO.md for the recording walkthrough, and SECURITY.md and SKILL.md for trust boundaries.
Apache-2.0. Copyright 2026 Mark Pickering and PICKBITS LLC. The full terms are in LICENSE, and attribution is in NOTICE.