I've received the following PGN text that I suspect invalid:

    {0.22/17 0 last book move}
    ( 8...b5 
       ( 8...Qb6 
           ( 8...Qc7 9.a3 

What exactly the position the moves come from is unimportant. Please note the PGN text has four 8th Black moves (8...e5, 8...b5, 8...Qb6, 8..Qc7), and two of them (8...Qb6 and 8..Qc7) are under 8..b5.

I suspect this is a mistake because the alternative Black moves should be represented like the diagram:

enter image description here

I generated the diagram with the Scid vs PC software. Please note the alternative Black moves are written in parallel. For example, 8...Qb6 and 8..Qc7 are not included inside the 8...b5 bracket.

Some softwares (e.g. Scid) are able to read it, but some fail (e.g. ChessX). My own PGN implementation can't handle the nested structure.

Q: Is the PGN text I posted valid? What does the PGN specification say?


The game is here. Open the game in a text editor, and you will see the following:

    { 0.22/17 237 } 
    ( 8...b5 
        ( 8...Qb6 
            ( 8...Qc7 9.a3 
  • Not an answer here, but I couldn't get the PGN to compile with my reader.
    – user1108
    Aug 1, 2017 at 8:17
  • I'll edit and post the whole game.
    – SmallChess
    Aug 1, 2017 at 8:17
  • @Bad_Bishop I edited and posted a link.
    – SmallChess
    Aug 1, 2017 at 8:23
  • Nope, still doesn't parse for me. But if I changed to (8...b5) (8...Qb6) etc. then it is fine.
    – user1108
    Aug 1, 2017 at 9:17
  • 1
    PgnViewer from Lokasoft (microsoft.com/en-gb/store/p/pgnviewer/9wzdncrdlzrh)
    – user1108
    Aug 1, 2017 at 9:21

1 Answer 1


Good question. This nested notation (also called: recursive annotation variation, RAV for short) is uncommon but valid[*]. In the example you provide, most online PGN readers have no problem parsing and accounting for all the variations and subvariations. So the way to read it is as follows: the nested structure is composed of independent variations, only if there's a closing parenthesis then it is an actual subvariation (so a specific branch out of a previous variation). An example from your PGN: 8... Qc7 is a variation, (9.Qe1...) is a subvariation and (10.Bf3...) is a subsubvariation. So the nesting is: (8... Qc7 (subvariation (subsubvar...) )).

Various libraries/modules may not have a built-in parsing system to tackle such PGN structure[**], so you may have to extend this on your own. For further reading, Tim Harding also explains the nested notation and its lack of implementation rather more succinctly here, I briefly quote:

An RAV (Recursive Annotation Variation) is a sequence of movetext containing one or more moves enclosed in parentheses. An RAV is used to represent an alternative variation. The alternate move sequence given by an RAV is one that may be legally played by first unplaying the move that appears immediately prior to the RAV. Because the RAV is a recursive construct, it may be nested. ...

Some software may find it hard to handle nested variations too. Palview3 was the first freely-available PGN software, that I am aware of, that could create with variations in HTML pages, and it is restricted to two levels of notes (three levels counting the actual moves of the game). For most purposes, this is sufficient. Most Java Viewers can only show the actually played moves, except as text notes, but playing through a Palview3 web page is close to the experience of playing it through in a program like ChessBase: a major advance for chess webmasters.

That said, nowadays, there are various online pgn-readers that already do this, some examples (so if you paste your PGN onto either of these, it can be fully read and displayed).

You may find additional information on the standards of PGN here. I will get back to you if I find other potentially useful elements.

[*]: just to make sure, I also quickly parsed the text to make sure all parentheses are properly closed.

[**]: for example, the chess.pgn.read_game method from python-chess fails to fully read this PGN, it only sees the main variation upto move 8... e5.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.