pdf-inspector CLI Guide - pdf2md & detect-pdf
API ReferenceCLI
pdf-inspector ships two command-line tools with the crate — cargo install pdf-inspector installs both in one go, no code required for classification or Markdown conversion. The npm package bundles the CLI too.
Install
# Rust toolchain users
cargo install pdf-inspector
# Or Node users (CLI bundled in the npm package)
npm install -g @firecrawl/pdf-inspectorYou get two executables:
| Tool | What it does | Typical time |
|---|---|---|
detect-pdf | Classify the document + analysis info | ~10–50ms |
pdf2md | Full parse; outputs Markdown | <200ms for text-based |
detect-pdf: ask "can I extract this directly?" first
# Quick verdict
detect-pdf document.pdf
# With analysis info + JSON output (recommended)
detect-pdf document.pdf --analyze --jsonThe most useful JSON fields:
{
"pdfType": "TextBased",
"confidence": 0.92,
"pagesNeedingOcr": []
}TextBased → run pdf2md with confidence. Scanned/Mixed → you know exactly which pages need OCR. This classify-first routing is the officially recommended way to keep costs down.
pdf2md: one command to Markdown
# Print to terminal
pdf2md annual-report.pdf
# Write to a file
pdf2md annual-report.pdf -o report.md
# Selected pages only
pdf2md annual-report.pdf --pages 1-3
# Structured JSON (metadata included, easy for programs)
pdf2md annual-report.pdf --json
# Token-saving compact output (before feeding LLMs)
pdf2md annual-report.pdf --compactFlags at a glance
| Usage | Meaning |
|---|---|
pdf2md <file> | Parse; Markdown goes to stdout |
pdf2md <file> -o out.md | Write to a file |
pdf2md <file> --pages 1-3 | Process selected pages only |
pdf2md <file> --select-pages | Interactively select pages |
pdf2md <file> --compact | Compact, token-saving output |
pdf2md <file> --json | Structured JSON output |
detect-pdf <file> | Quick classification |
detect-pdf <file> --analyze --json | Classification + analysis |
Common combinations
Batch-convert a directory
for f in *.pdf; do
pdf2md "$f" -o "${f%.pdf}.md"
doneA classify-first routing script
type=$(detect-pdf "$f" --analyze --json | jq -r '.pdfType')
if [ "$type" = "TextBased" ]; then
pdf2md "$f" -o "${f%.pdf}.md"
else
echo "Skipping $f: $type needs OCR"
fiPipe it onward
pdf2md annual-report.pdf --compact | your-llm-loaderTips
- The first
cargo installcompiles for a few minutes; after that everything runs at native speed - Prebuilt binaries exist for Windows, macOS ARM, and Linux x64/ARM64 — the npm route skips compilation entirely
- For every flag, trust the repo README and
--help