Overview
Packages that turn PDFs, webpages and YouTube videos into clean, structured text, in Node, the browser and Cloudflare Workers.
Try the live demo
Convert a PDF or extract a webpage on the Worker that serves these docs.
extract-pdf
A PDF to structured HTML, with OCR only for the pages that need it.
extract-webpage
Any URL to its main content and a citation.
extract-youtube
Any YouTube video to its transcript, with a floating player and video library for React.
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:
| Package | Input | Output |
|---|---|---|
extract-pdf | A PDF URL or ArrayBuffer | Structured 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-webpage | A URL, an HTML string, a DOM document, or a DOCX buffer | The main content as basic HTML, plus title, author, date, publisher, an APA-style citation and a word count. |
extract-youtube | A YouTube video id or URL | The 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-youtubeA 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
- Live demo: what the demo runs, its API, and how to deploy your own.
- extract-pdf: options, parse methods, OCR and running on Workers.
- extract-webpage: citations, scraping and text tools.
- extract-youtube: transcripts, formatters, the floating player, the video grid and the library admin API. Try them on the YouTube tab of the live demo.