If there have only been 21 Pope Johns, why has the numbering reached up to 23 in John XXIII and why has there never been a John XX?
John XX was skipped because of an error in John XIV’s entry in the Liber Pontificalis. His entry contained the duration of his pontificate, but also the duration of his imprisonment by Antipope Boniface VII. In the 11th century, some time after John XIX, this entry on John XIV was misread to be referring to two different popes named John, the first reigning for eight months and directly succeeded by another reigning for four months:
Iohannes m. VIII (“John, eight months”)
Iohannes m. IV (“John, four months”)
The second fictional John one came to be known as Iohannes XIV. bis, meaning John XIV the second, who became confused with a cardinal deacon John who opposed antipope Boniface VII after John XIV’s death. Since John XV through XIX seemed to have neglected the existence of the second John XIV, Pedro Julião took the name John XXI to “correct” the error in papal naming, not realizing he himself was making a mistake.
Since the error was discovered in the 19th century, the popes are now listed using the numbers they used during their reigns and there was never a John XX.
There was also a antipope John XVI from 997 to 998, and despite being an antipope his regnal number of 16 was kept in the Liber Pontificalis.
Hence, there being 2 less Pope Johns than the numbering of the latest Pope John XXIII.