The official JavaScript/TypeScript SDK for Ragparser.com, an API that turns PDF documents into clean Markdown, plain text, and structured JSON, ready to feed into LLMs, RAG pipelines, and AI agents.
No Python, no Docker, no GPU instances to manage. One HTTP request replaces a whole self-hosted parsing stack (PyMuPDF, pdfplumber, Docling, Marker, and so on). Ragparser picks the right engine for each document automatically and returns Markdown with headings, tables, lists, and block quotes preserved.
- PDF to Markdown, instantly. Get LLM-ready Markdown and plain text from any PDF in one API call.
- Built for RAG and AI pipelines. Clean, chunkable output that's easy to embed into a vector database or knowledge base.
- Zero infrastructure. No parsing stack to host or maintain, just an API key and an HTTP request.
- Smart parsing. Automatically picks the best engine for the document's complexity, including table detection.
- Secure by default. Files are parsed in memory and deleted immediately, never stored.
- Free to start. 100 PDFs a month on the free tier, no card required.
npm install ragparser- Sign up at ragparser.com to grab a free API key (100 PDFs/month, no card required).
- Install the SDK and parse your first PDF:
import { RagparserClient } from "ragparser";
const client = new RagparserClient("YOUR_API_KEY");
// file: a File object (browser input, or Node.js 18+ File/Blob)
const result = await client.parse(file);
console.log(result.markdown); // clean Markdown, ready for your LLM/RAG pipeline
console.log(result.text); // plain text
console.log(result.metadata); // author, creator, language, page countYou can also parse a PDF directly from a URL instead of uploading a file:
const result = await client.parse({ url: "https://example.com/document.pdf" });Wrap calls in a try/catch to handle bad API keys, invalid files, or network issues:
import { RagparserClient, RagparserError } from "ragparser";
try {
const result = await client.parse(file);
console.log(result.markdown);
} catch (error) {
if (error instanceof RagparserError) {
console.error(`Ragparser error (${error.status ?? "n/a"}): ${error.message}`);
} else {
throw error;
}
}Creates a new client authenticated with your Ragparser API key. Every request is authenticated with this key as a Bearer token. Throws a RagparserError if the key is missing or empty.
Sends the PDF as multipart form-data to POST /v1/parse (max 25 MB) and returns its parsed contents. input can be:
- A
FileorBlob(browser input, or Node.js 18+), or - An object
{ url: string }, in which case the SDK downloads the file from that URL first and uploads it for you.
interface ParseResponse {
success: true;
pages: number;
title: string | null;
markdown: string;
text: string;
metadata: {
author: string | null;
creator: string | null;
language: string | null;
pageCount: number;
};
}Every failure, a missing API key, an invalid PDF, a bad URL, a network hiccup, or a non-2xx response from the API, is thrown as a RagparserError (extends Error) with an optional status matching the API's HTTP status code (401, 429, 500, etc.) where applicable.
The full API reference, request/response formats, error codes, and rate limits live at ragparser.com/docs.
The short version: there's a single endpoint, POST /v1/parse, authenticated with a Bearer token in the Authorization header. You upload a PDF as multipart/form-data under a file field and get back JSON with the parsed Markdown, plain text, and metadata. Invalid or oversized files return a 400, and rate limits depend on your plan (100 PDFs/month free, 5,000/month on Pro).
Since it's a plain HTTP API, it works from any language or runtime. This package is just a small, typed convenience wrapper for JavaScript and TypeScript.
client.parse relies on the global fetch, FormData, and Blob APIs, which work natively in browsers and in Node.js 18+.
MIT