npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

ai-form-response-extractor

v0.1.5

Published

Hybrid paper + digital form collection powered by multimodal LLMs

Readme

ai-form-response-extractor

CI npm version License: MIT

Hybrid paper + digital form collection powered by multimodal LLMs.

Design a form once, collect responses online and on paper, then use AI to extract structured data from scanned/photographed paper forms and merge everything together.

A lightweight, open-source alternative to enterprise IDP solutions like Rossum, ABBYY FlexiCapture, and Hyperscience.

Features

  • SurveyJS-first — First-class adapter for SurveyJS JSON form definitions
  • Multi-provider LLMs — OpenAI, Anthropic, Ollama (local models) out of the box
  • Intelligent extraction — Text, checkboxes, tables, handwriting from scanned forms
  • Multi-page extraction — Pass an ordered array of page images for multi-page paper forms
  • Native PDF extraction — Pass digital PDFs directly to providers that support document inputs
  • QR / unique ID detection — Automatic form identification from images
  • Confidence scoring — Flag low-confidence fields for human review
  • Response merging — Combine online + paper responses by unique ID
  • Schema-aware prompting — LLM outputs validated against your form schema with Zod

Installation

npm install ai-form-response-extractor

Quick Start

import { createExtractor } from 'ai-form-response-extractor';
import { openai } from 'ai-form-response-extractor/providers';
import { readFileSync } from 'fs';

// 1. Create an extractor with your preferred LLM provider
const extractor = createExtractor({
  provider: openai('gpt-4o'),
  adapter: 'surveyjs',
  options: {
    confidenceThreshold: 0.75,
    maxRetries: 2,
  }
});

// 2. Load your form input (scanned image(s) or native PDF) and form definition
const image = [
  readFileSync('./scanned-form-page-1.png'),
  readFileSync('./scanned-form-page-2.png'),
];
const formDefinition = JSON.parse(readFileSync('./survey.json', 'utf-8'));

// 3. Extract structured data from the provided form input
const result = await extractor.extractFromImage({
  image,
  formDefinition,
});

console.log(result.data);          // Structured responses matching schema
console.log(result.uniqueId);      // Detected QR / barcode ID
console.log(result.confidence);    // Per-field confidence scores

// Single-page forms are also supported:
// image: readFileSync('./scanned-form.png')
// Native PDF is also supported for providers with document input support:
// image: readFileSync('./digital-form.pdf')

PDF Provider Notes

  • OpenAI provider: supports native PDF input.
  • Anthropic provider: supports native PDF input.
  • Ollama provider: current API path is image-only and does not accept native PDF input.

Switching Providers

import { openai, anthropic, ollama } from 'ai-form-response-extractor/providers';

// OpenAI
createExtractor({ provider: openai('gpt-4o') });

// Anthropic
createExtractor({ provider: anthropic('claude-4-sonnet') });

// Local with Ollama (no API key needed)
createExtractor({ provider: ollama('llama-3.2-vision') });

Standalone Utilities

import { detectUniqueId, mergeResponses } from 'ai-form-response-extractor';

// Detect QR code or unique ID from an image
const id = await detectUniqueId(imageBuffer);

// Merge online and paper responses
const merged = mergeResponses(onlineResponses, paperExtractions);

Adapters

| Adapter | Description | |---------|-------------| | surveyjs | Converts SurveyJS JSON into optimized LLM prompts | | json-schema | Standard JSON Schema support | | custom | Bring your own adapter via a simple interface |

Limitations

  • signature and signaturepad fields are intentionally not extracted.
  • Signatures belong to the source document context and do not make sense as standalone structured data without the original document.

Environment Variables

| Variable | Description | |----------|-------------| | OPENAI_API_KEY | OpenAI API key | | ANTHROPIC_API_KEY | Anthropic API key | | OLLAMA_BASE_URL | Ollama server URL (default: http://localhost:11434) |

Demo

See the ai-form-response-extractor-demo repository for a full working demo.

Documentation

Development

# Install dependencies
npm install

# Build
npm run build

# Run tests
npm test

# Lint
npm run lint

Contributing

Contributions are welcome! Please read the spec and build plan before starting work.

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/my-feature)
  3. Commit your changes (git commit -m 'Add my feature')
  4. Push to the branch (git push origin feature/my-feature)
  5. Open a Pull Request

License

MIT