Overview

Packages that turn PDFs, webpages and YouTube videos into clean, structured text, in Node, the browser and Cloudflare Workers.

When people hand a research tool a document, they expect an answer at once, not after minutes of OCR. These packages are built around that:

PackageInputOutput
extract-pdfA PDF URL or ArrayBufferStructured HTML (headings, lists, footnotes, code and quote blocks, Table of Contents links), the title and author, and a per-page scan of which pages would benefit from OCR.
extract-webpageA URL, an HTML string, a DOM document, or a DOCX bufferThe main content as basic HTML, plus title, author, date, publisher, an APA-style citation and a word count.
extract-youtubeA YouTube video id or URLThe transcript as timed snippets, or as text, SRT, WebVTT or an article. Optional React components: a floating player with synced captions, a transcript modal, a video grid and list, and library admin screens.

extract-webpage uses extract-pdf itself: a URL that turns out to be a PDF is converted by it. A YouTube URL is handed to extract-youtube, so it comes back as its transcript.

Install

npm i extract-pdf extract-webpage extract-youtube
# or
bun add extract-pdf extract-webpage extract-youtube

A first call

import { convertPDFToHTML } from 'extract-pdf';
import { extractContent } from 'extract-webpage';
import { YouTubeTranscriptApi } from 'extract-youtube';

const pdf = await convertPDFToHTML('https://arxiv.org/pdf/1706.03762');
const page = await extractContent('https://en.wikipedia.org/wiki/Web_scraping');
const transcript = await new YouTubeTranscriptApi().fetch('dQw4w9WgXcQ');

console.log(pdf.title, pdf.ocrScan.pagesNeedingOcr);
console.log(page.cite, page.word_count);
console.log(transcript.toRawData().slice(0, 3)); // [{ text, start, duration }, …]

Where to go next

On this page