# Deterministic Invoice & Receipt Text-to-JSON Normalizer (`n4d.h1dr/invoice-receipt-json-normalizer`) Actor

Standardizes messy OCR text and receipt strings into clean, structured accounting JSON with vendor, date, line items, and totals without expensive LLM API fees.

- **URL**: https://apify.com/n4d.h1dr/invoice-receipt-json-normalizer.md
- **Developed by:** [Nadim Hider](https://apify.com/n4d.h1dr) (community)
- **Security:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $1.00 / 1,000 processed items

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## Deterministic Invoice & Receipt Text-to-JSON Normalizer

A resilient, ultra-fast financial document parser that transforms unformatted OCR text dumps, email receipts, and digital invoice strings into standardized accounting JSON. Extracts merchant/vendor, invoice number, ISO 8601 date, currency, subtotal, tax/VAT, grand total, and itemized line items without calling expensive LLM APIs.

***

### 🚀 Why Use This Actor?

Using LLMs (like GPT-4o or Claude 3.5) for high-volume receipt and invoice intake costs $0.02 to $0.05 per document and suffers from token latency and non-deterministic formatting errors. This Actor provides a deterministic alternative:

- **100x Lower Costs**: Billable at only $0.001 per invoice, cutting automated bookkeeping expenses by 95%+.
- **Zero Hallucinations**: Uses strict regex, financial token parsing, and currency heuristics. Numbers add up exactly as stated on the receipt.
- **Automated ISO 8601 Date Parsing**: Handles standard international date formats (`YYYY-MM-DD`, `DD/MM/YYYY`, `MM/DD/YYYY`, and month names).
- **Line Item Extraction**: Automatically extracts product descriptions, quantities, unit prices, and line totals.
- **ERP & Accounting Integration**: Feeds cleanly into QuickBooks, Xero, NetSuite, Google Sheets, or Airtable via Make/n8n.

***

### 📥 Input Schema

| Field | Type | Default | Description |
|---|---|---|---|
| `invoices` | Array | *Sample Receipt* | Array of objects containing `invoice_id` and raw `raw_text` strings. |
| `default_currency` | String | `"USD"` | Fallback ISO currency code if no symbol is detected. |

#### Sample Input JSON

```json
{
  "invoices": [
    {
      "invoice_id": "INV-2026-01",
      "raw_text": "GitHub Inc.\nInvoice #GH-88192\nDate: 2026-10-01\nCopilot Enterprise  5  $39.00  $195.00\nSubtotal: $195.00\nTax: $0.00\nTotal: $195.00"
    }
  ],
  "default_currency": "USD"
}
```

***

### 📤 Output Dataset Format

```json
{
  "invoice_id": "INV-2026-01",
  "vendor_name": "GitHub Inc.",
  "invoice_number": "GH-88192",
  "invoice_date_iso": "2026-10-01T00:00:00+00:00",
  "currency": "USD",
  "subtotal": 195.0,
  "tax_amount": 0.0,
  "total_amount": 195.0,
  "line_items": [
    {
      "description": "Copilot Enterprise",
      "quantity": 5,
      "unit_price": 39.0,
      "line_total": 195.0
    }
  ],
  "confidence_score": 100.0,
  "status": "success"
}
```

***

### 💰 Pay-Per-Event (PPE) Pricing

- **Event Name**: `item-processed`
- **Cost**: Only **$0.001 per invoice** ($1.00 per 1,000 invoices processed).
- Outcompetes manual data entry and expensive OCR SaaS APIs with instantaneous throughput and zero setup overhead.

***

### 🔌 API & Python Client Example

```python
from apify_client import ApifyClient

client = ApifyClient("YOUR_APIFY_TOKEN")

run = client.actor("YOUR_USERNAME/invoice-receipt-json-normalizer").call(run_input={
    "invoices": [
        {"invoice_id": "receipt_1", "raw_text": "Office Depot\nTotal: $45.20\nDate: 2026-08-14"}
    ]
})

for item in client.dataset(run["defaultDatasetId"]).iterate_items():
    print(f"Vendor: {item['vendor_name']} | Total: {item['currency']} {item['total_amount']}")
```

# Actor input Schema

## `invoices` (type: `array`):

List of raw text documents or OCR dumps representing invoices or receipts.

## `default_currency` (type: `string`):

Fallback currency code if not explicitly detected from currency symbols.

## Actor input object example

```json
{
  "invoices": [
    {
      "invoice_id": "demo-receipt-001",
      "raw_text": "ACME Cloud Services Inc.\n123 Innovation Way, Tech City\nINVOICE: INV-2026-9481\nDate: 2026-10-15\n\nDescription              Qty   Price    Total\nCloud Compute Tier A      2    $40.00   $80.00\nManaged Storage 500GB     1    $25.00   $25.00\n\nSubtotal: $105.00\nTax (10%): $10.50\nTotal Due: $115.50\nPayment Method: VISA ending in 4242"
    }
  ],
  "default_currency": "USD"
}
```

# Actor output Schema

## `results` (type: `string`):

No description

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "invoices": [
        {
            "invoice_id": "demo-receipt-001",
            "raw_text": "ACME Cloud Services Inc.\n123 Innovation Way, Tech City\nINVOICE: INV-2026-9481\nDate: 2026-10-15\n\nDescription              Qty   Price    Total\nCloud Compute Tier A      2    $40.00   $80.00\nManaged Storage 500GB     1    $25.00   $25.00\n\nSubtotal: $105.00\nTax (10%): $10.50\nTotal Due: $115.50\nPayment Method: VISA ending in 4242"
        }
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("n4d.h1dr/invoice-receipt-json-normalizer").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = { "invoices": [{
            "invoice_id": "demo-receipt-001",
            "raw_text": """ACME Cloud Services Inc.
123 Innovation Way, Tech City
INVOICE: INV-2026-9481
Date: 2026-10-15

Description              Qty   Price    Total
Cloud Compute Tier A      2    $40.00   $80.00
Managed Storage 500GB     1    $25.00   $25.00

Subtotal: $105.00
Tax (10%): $10.50
Total Due: $115.50
Payment Method: VISA ending in 4242""",
        }] }

# Run the Actor and wait for it to finish
run = client.actor("n4d.h1dr/invoice-receipt-json-normalizer").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "invoices": [
    {
      "invoice_id": "demo-receipt-001",
      "raw_text": "ACME Cloud Services Inc.\\n123 Innovation Way, Tech City\\nINVOICE: INV-2026-9481\\nDate: 2026-10-15\\n\\nDescription              Qty   Price    Total\\nCloud Compute Tier A      2    $40.00   $80.00\\nManaged Storage 500GB     1    $25.00   $25.00\\n\\nSubtotal: $105.00\\nTax (10%): $10.50\\nTotal Due: $115.50\\nPayment Method: VISA ending in 4242"
    }
  ]
}' |
apify call n4d.h1dr/invoice-receipt-json-normalizer --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,n4d.h1dr/invoice-receipt-json-normalizer"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/y4QTjRLSWn4cOMD2v/builds/mqXa5P8VGCF6IjHGn/openapi.json
