Tools,

PDF to BibTeX, free and tested

206 of 241

references fully right from 8 papers

Get refs2bib.sh

One command, one .bib file

refs2bib.sh sends a PDF to GROBID on your computer. Out come the paper's own entry and one entry a reference.

refs2bib.sh

docker run --rm --init --ulimit core=0 -p 8070:8070 grobid/grobid:0.9.1-crf
sh refs2bib.sh paper.pdf > paper.bib

Nothing leaves your computer. For a scan it runs OCRmyPDF first.

What do the two fixes change?
  • GROBID writes a book as @inbook with its title only in booktitle. The script makes it a @book with a title. That fixed 19 of 20 such entries.
  • GROBID repeated a key 5 times. BibTeX keeps only one entry for a key. The script adds _2, _3 and so on.

GROBID found 236 of 241 references

8 arXiv papers, 241 references. Fully right: title, first author and year
Way Found Fully right
refs2bib.sh (GROBID and the two fixes) 236 206
GROBID 0.9.1, BibTeX as it comes 236 190
GROBID with its CrossRef lookup 229 189
AnyStyle find --no-layout 197 170
AnyStyle find 119 68

93 of 94 DOIs the PDFs print or link, from GROBID

29 of 30 unprinted DOIs added by the CrossRef lookup

The lookup sends each reference to CrossRef. It took 14 to 44 s a paper, GROBID alone 2.2 to 2.6 s.

A scan needs OCR first

The top of a reference list on a gray, slightly tilted simulated scan, entries 1 to 6
Page 9 as a simulated scan (Oberle, Berriaud and Wattenhofer, CC BY 4.0, via arXiv). GROBID found 0 of its 22 references, then 19 fully right after OCR.
The same 8 papers as simulated 300 dpi scans, 241 references
Way Found Fully right
GROBID on the scan as it is 0 0
OCRmyPDF, then refs2bib.sh 231 181
Our Actor's text, then AnyStyle 164 117
OCRmyPDF, then AnyStyle --no-layout 145 68
OCRmyPDF, then AnyStyle 130 52

A scan loses the links: GROBID read 28 of the 34 DOIs printed as text.

The paper's own entry: pdf2bib

Own entry fully right: title, all authors and year, of 8
Way PDF Scan
pdf2bib 1.2 (online) 8 0
GROBID, offline 4 0

arXiv writes each paper's DOI into the PDF's file info, and pdf2bib read it there. A scan has no such field: it returned the entry of a cited paper 4 times.

Two warnings from its docs: with no DOI it searches Google with text from your PDF, and it writes the DOI into your PDF unless you add -nostore.

What still went wrong

Scanned paper? Our Actor reads it

Our Apify Actor reads scanned pages into text. Ask only for page 1 and the reference pages, then let AnyStyle parse them.

That beat AnyStyle on OCRmyPDF's file: 117 references fully right against 52 and 68. A scanned page costs $0.006, and pages with a text layer are free.

curl -s -X POST "https://api.apify.com/v2/acts/brasspage~pdf-ocr-to-markdown/run-sync-get-dataset-items" \
  -H "Authorization: Bearer $APIFY_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"documentUrls": ["https://example.com/scan.pdf"], "pages": "1, 9-10", "outputFormat": "text"}' \
  | jq -r '.[].text' > paper.txt
anystyle -f bib find paper.txt .

Try the Actor

How I tested it
  • Papers: 8 arXiv papers with a CC BY 4.0 license, in physics, statistics, economics, math, biology, signal processing, game theory and language. 135 pages.
  • Styles: APS (2 papers), SIAM, IEEE, ACM, and 3 author-year styles. Credit: the authors, via arXiv.
  • Truth: the authors' own .bib entries for the keys each paper cites. Every true title is in the printed list, and the 5 numbered lists have the same count.
  • Found: an entry pairs with a true reference by its title. Right means the same letters and digits, with case, accents and punctuation ignored.
  • Scans: each page at 300 dpi gray, tilted up to 0.6 degrees, with noise, saved as JPEG. Renders, not real scans.
  • GROBID 0.9.1 CRF image in Docker on 2 cores, no lookup unless named. AnyStyle 1.6.0, pdf2bib 1.2, OCRmyPDF 17.13.0 with Tesseract 5.5.4.
  • The Actor's code at build 0.1.97 read 23 pages of the scans: 0 errors, 9.8 s a page on our Mac.
  • refs2bib.sh on 2 scans, OCR and all, scored the same as the bench files.
  • Not tested: the GROBID full image, CERMINE, Zotero's Retrieve Metadata, real scans, books and theses.

Questions people ask

How do I convert a PDF to BibTeX for free?

Run GROBID on your computer with Docker, then refs2bib.sh paper.pdf. It writes the paper's own entry and one entry for each reference. It got 206 of 241 references fully right on our 8 test papers.

Does GROBID work on scanned PDFs?

Not by itself. GROBID does no OCR, so it found 0 references on our scans. After OCRmyPDF it found 231 of 241. refs2bib.sh runs OCRmyPDF first when a PDF has no text layer.

What is the best free tool for the paper's own BibTeX entry?

pdf2bib got all 8 of our arXiv papers fully right, because it reads the DOI that arXiv puts in the PDF's file info. It needs the internet. GROBID got 4 of 8 offline.