Smart Conversion

Extract text from any document

Smart text extraction that automatically detects the input format and uses the appropriate extraction method.

Supported Formats

  • PDF: Native text extraction, falls back to OCR for scanned PDFs
  • DOCX: Microsoft Word documents
  • XLSX: Microsoft Excel (extracts cell contents)
  • PPTX: Microsoft PowerPoint (extracts slide text)
  • Images: PNG, JPEG, TIFF, BMP (uses OCR)
  • HTML: Extracts visible text content

How It Works

  1. Detects file format from content (not just extension)
  2. Routes to appropriate extraction module
  3. For PDFs: tries native extraction first, falls back to OCR if no text found
  4. Returns extracted text with metadata about source format

Example Usage

import httpx

with open("document.pdf", "rb") as f:
    response = httpx.post(
        "https://api.filegraph.ai/any/to-text",
        headers={"X-API-Key": "your-api-key"},
        files={"file": f},
    )
print(response.json()["text"])
post/any/to-text

Request

  • Base URL: https://api.filegraph.ai (the document declares no server; this is the origin it was published from)
  • URL: https://api.filegraph.ai/any/to-text
  • Auth: API key in header X-API-Key

Query parameters

ocr_languagestring
ocr_fallbackboolean

Response

Text successfully extracted

textstring required

Extracted text content

format_detectedstring required

Detected input format (e.g., 'pdf', 'docx', 'image')

word_countinteger required

Number of words extracted

char_countinteger required

Number of characters extracted

used_ocrboolean required

Whether OCR was used for extraction

metadataobject

Additional format-specific metadata

Example response

{
  "char_count": 892,
  "format_detected": "pdf",
  "metadata": {
    "page_count": 3
  },
  "text": "This is the extracted text from the document...",
  "used_ocr": false,
  "word_count": 150
}

Changes

No recorded changes to this operation across all 1 revision of this API.