Prompt

OCR to JSON API for documents

Artificial Intelligence / Computer Vision1 observationLast seen Oct 11, 2026

Latest observation

Oct 11, 2026OpenAI APIWeb search: off

Here’s a practical OCR-to-JSON API design for document processing.

What it does

  • Accepts document uploads: PDF, JPG, PNG, TIFF
  • Runs OCR to extract text
  • Returns structured JSON with:
    • full text
    • page data
    • word/line boxes
    • confidence scores
    • optional fields like tables, key-value pairs, and language

Example API endpoints

1) Upload document

POST /v1/ocr

Request

Content-Type: multipart/form-data

Form fields

  • file: document file
  • output_format: json (default)
  • detect_tables: true|false
  • detect_key_values: true|false
  • language: optional, e.g. eng, spa, auto

Response

{
  "job_id": "ocr_12345",
  "status": "queued"
}

2) Check job status

GET /v1/ocr/{job_id}

Response

{
  "job_id": "ocr_12345",
  "status": "completed"
}

3) Get OCR result

GET /v1/ocr/{job_id}/result

Response

{
  "job_id": "ocr_12345",
  "status": "completed",
  "document": {
    "filename": "invoice.pdf",
    "page_count": 2,
    "language": "eng"
  },
  "pages": [
    {
      "page नंबर": 1,
      "width": 2480,
      "height": 3508,
      "text": "Invoice #123 ...",
      "lines": [
        {
          "text": "Invoice #123",
          "confidence": 0.98,
          "bbox": [120, 80, 420, 120]
        }
      ],
      "words": [
        {
          "text": "Invoice",
          "confidence": 0.99,
          "bbox": [120, 80, 220, 120]
        }
      ]
    }
  ]
}

Recommended JSON schema

A good OCR JSON structure:

{
  "job_id": "string",
  "status": "string",
  "document": {
    "filename": "string",
    "mime_type": "string",
    "page_count": "integer",
    "language": "string"
  },
  "pages": [
    {
      "page_number": "integer",
      "width": "integer",
      "height": "integer",
      "rotation": "integer",
      "text": "string",
      "blocks": [
        {
          "type": "paragraph|table|title|list",
          "text": "string",
          "confidence": "number",
          "bbox": [0, 0, 0, 0]
        }
      ],
      "lines": [
        {
          "text": "string",
          "confidence": "number",
          "bbox": [0, 0, 0, 0]
        }
      ],
      "words": [
        {
          "text": "string",
          "confidence": "number",
          "bbox": [0, 0, 0, 0]
        }
      ]
    }
  ],
  "tables": [
    {
      "page_number": 1,
      "bbox": [0, 0, 0, 0],
      "rows": [
        ["cell1", "cell2"]
      ]
    }
  ],
  "key_values": [
    {
      "key": "Invoice Number",
      "value": "12345",
      "confidence": 0.97
    }
  ]
}

Error response example

{
  "error": {
    "code": "unsupported_file_type",
    "message": "Only PDF, PNG, JPG, TIFF are supported."
  }
}

Optional features to add

  • Async processing for large files
  • Webhook callback when OCR finishes
  • Searchable text output
  • Bounding boxes in normalized coordinates
  • Table extraction
  • Form extraction
  • Handwriting recognition
  • Multi-language OCR
  • Page image thumbnails

If you want to build it

A common stack:

  • API: FastAPI / Express / Flask
  • OCR engine: Tesseract, PaddleOCR, AWS Textract, Google Vision, Azure OCR
  • Storage: S3 / local blob store
  • Queue: Celery / Redis / RabbitMQ
  • DB: PostgreSQL for jobs and metadata

If you want, I can also give you:

  1. a full OpenAPI spec,
  2. a FastAPI implementation, or
  3. a JSON schema for the OCR response.

Observation history

How did Obsurfable measure this prompt?

Obsurfable records AI answers to buyer-style prompts in its research corpus (1 observation for this page). Metrics are distributions over observations, not a single static ranking.

Which AI systems does Obsurfable collect answers from?

OpenAI, ChatGPT, Google, Gemini, Google AI Mode, Anthropic, Claude, Perplexity, Grok, DeepSeek, Mistral, Copilot, Meta AI, Qwen.

How can brands improve their AEO?

Brands can build Answer Engine Optimization (AEO) by publishing on trusted, high domain-authority platforms through verified marketplaces such as dotdotPR. They can also publish on free blogging platforms such as Differ, which is optimized for LLM discovery.

Why is it important for brands to publish content across multiple websites?

Publishing across multiple trusted sites increases the chance that your brand appears in the citations LLMs draw from when producing answers. Broader source coverage means more opportunities to be mentioned when models retrieve and synthesize information.

Want this interpreted for your brand?

Explorer is the free public corpus. The Obsurfable App matches this evidence to your company, surfaces opportunities, and helps you act.