I was expecting a `,' or a `}'---line <n> of file <name>.bib

A .bib entry is malformed, most often a missing comma between fields or a space in the key. BibTeX skips the rest of the entry.

Help centre › LaTeX errors › References and bibliography · Error: the build stops or the output is wrong

What the log says

Database file #1: refs.bib
I was expecting a `,' or a `}'---line 4 of file refs.bib
 :
 :   title   = {Measuring Things Carefully},
(Error may have been on previous line)
I'm skipping whatever remains of this entry

What it means

BibTeX reads each entry as a key followed by fields of the form name = value, separated by commas. After a key or a value it expects either a comma (another field follows) or the closing brace of the entry. It found something else, so it gives up on the rest of that entry. Fields after the error are lost and the entry may come out incomplete.

Causes and fixes

Most common first. Each example is a complete document; the first fails with this message, the second is the same document fixed.

1. A comma is missing at the end of the previous field

The line BibTeX names is usually the field after the mistake, which is why it adds "Error may have been on previous line". Add the comma at the end of the field above.

Fails
\begin{filecontents*}[overwrite]{refs.bib}
@article{smith2020,
  author  = {Smith, Jane}
  title   = {Measuring Things Carefully},
  journal = {Journal of Measurement},
  year    = {2020}
}
\end{filecontents*}
\documentclass{article}
\begin{document}
As shown by \cite{smith2020}, the effect is small.
\bibliographystyle{plain}
\bibliography{refs}
\end{document}
Fixed
\begin{filecontents*}[overwrite]{refs.bib}
@article{smith2020,
  author  = {Smith, Jane},
  title   = {Measuring Things Carefully},
  journal = {Journal of Measurement},
  year    = {2020}
}
\end{filecontents*}
\documentclass{article}
\begin{document}
As shown by \cite{smith2020}, the effect is small.
\bibliographystyle{plain}
\bibliography{refs}
\end{document}

2. The citation key contains a space

A key ends at the first space. Remove spaces from keys (smith2020, smith_2020) and update the \cite commands to match.

Fails
\begin{filecontents*}[overwrite]{refs.bib}
@article{smith 2020,
  author  = {Smith, Jane},
  title   = {Measuring Things Carefully},
  journal = {Journal of Measurement},
  year    = {2020}
}
\end{filecontents*}
\documentclass{article}
\begin{document}
As shown by \cite{smith2020}, the effect is small.
\bibliographystyle{plain}
\bibliography{refs}
\end{document}
Fixed
\begin{filecontents*}[overwrite]{refs.bib}
@article{smith2020,
  author  = {Smith, Jane},
  title   = {Measuring Things Carefully},
  journal = {Journal of Measurement},
  year    = {2020}
}
\end{filecontents*}
\documentclass{article}
\begin{document}
As shown by \cite{smith2020}, the effect is small.
\bibliographystyle{plain}
\bibliography{refs}
\end{document}

3. A value contains a double quote inside a quoted value

In title = "…", an inner " ends the value early. Delimit the value with braces instead, title = {The "best" method}, or write the inner quotes as ` ` ` and ''`.

4. Braces in a value are unbalanced

Every { in a value needs its }. An extra or missing brace shifts where BibTeX thinks the field ends. Count the braces in the field named in the message and the one before it.

In Manulyx

The editor reports the error at the line of the .bib file BibTeX names, with an explanation, and lists the citations it leaves undefined under it.

Write in Manulyx for free · Journal templates

More in references and bibliography

Every example on this page was compiled with pdfLaTeX and BibTeX to check that it fails and is fixed as described. All LaTeX errors