Kif is probably the most popular file format used to represent not only full shogi games, but also studies of games, tsume problems and other types of puzzles.
The aim of this post is to explain this format, in case you are not fully familiar with it. If you spot any inaccuracies, typos or you feel that something isn't explained properly, please submit an issue on github. First let's take a look how a KIF file looks.
1  ７六歩(77) ( 0:00/00:00:00)
2  ８四歩(83) ( 0:00/00:00:00)
3  ５六歩(57) ( 0:00/00:00:00)
4  ５四歩(53) ( 0:00/00:00:00)
5  ５八飛(28) ( 0:00/00:00:00)
6  ４二金(41) ( 0:00/00:00:00)
7  ５五歩(56) ( 0:00/00:00:00)
8  同 歩(54) ( 0:00/00:00:00)
9  同 角(88) ( 0:00/00:00:00)
10  ８五歩(84) ( 0:00/00:00:00)
11  ７三角成(55) ( 0:00/00:00:00)
8   ５二飛(82) ( 0:00/00:00:00)
Header contains general information about the game or study. Every tag starts at a new line, the tag name and tag value is separated by '：'.
While everyone can use their own tags, to convey whatever information they want, there are some tags, that a lot of kif files share. So let's look at the most important tags here.
Sente's (black's) player name. This can include titles, ranks, etc. 下手 should be used in handicap games. This field is often required, even if the name of the player is unknown or not relevant (for example in puzzles).
Gote's (white's) player name. This can include titles, ranks, etc. 上手 should be used in handicap games. This field is often required, even if the name of the player is unknown or not relevant (for example in puzzles).
Type of handicap. This specifies initial position of the game, for standard starting position 「平手」 is used. This doesn't always mean the moves provided in the kif file necessarily start at this position, only that the game started at that position (for example in studies of games we might include only the relevant part of the game, but still keeping this tag to know how the game started), if that's the case, specific board setup is provided - next field. For list of handicaps see Editor.
Games from non-standard positions, tsume problems, etc. need to specify the initial board position. Works very similarly to SFEN. We display the board from sente's view. Gote's pieces are preceded by 'v'. For promoted pieces we use single kanji variants. Pieces in hand are shown above and below the board, if player has no pieces in hand , we write「なし」. If it's gote's turn 後手番 is noted on a new line.
９ ８ ７ ６ ５ ４ ３ ２ １
| ・ ・ ・v桂 ・ ・ ・ ・ ・|一
|v玉 角v歩 馬 ・ ・ ・ ・ ・|二
| ・ ・ ・ ・ ・ ・ ・ ・ ・|三
| 桂 ・ ・v歩 ・ ・ ・ ・ ・|四
|vとv桂 ・ ・v歩 ・ ・ ・ ・|五
| ・ ・ 飛 ・v全 ・ ・ ・ ・|六
|v歩 桂 ・ ・ ・ ・ ・ ・ ・|七
| ・ 香 ・ ・ ・ ・ ・ ・ ・|八
| ・v銀 ・ ・ 龍 ・ ・ ・ ・|九
Start date of the game, time can also be specified. The most common format is yyyy/MM/dd HH:mm:ss.
End date of the game, time can also be specified. The most common format is also yyyy/MM/dd HH:mm:ss.
Name of the tournament where the game was played. Lishogi also uses this field for the type of the game.
Location where the game occurred. Either real physical location or internet site/application.
Initial time of the game. Byoyomi might be included in this field or additional field 「秒読み」 is included if necessary. First example means the same thing as the last two lines together.
Game opening that was played.
For tsume puzzles additional set of tags is commonly used - author of the puzzle, where it was published, etc. Take a look here, if you are interested.
File is represented by full-width number and rank by Japanese numeral. If the destination is the same as the last one 「同 」 is used (note the space after 同). It's essentially the same as in standard Japanese notation.
If you are familiar with Japanese move notation, this shouldn't surprise you, because it's the same.
If the piece is being promoted 「成」 is noted. If a non-promotion by choice occurs, 「不成」 is not noted.
Origin square is always noted by two half-width numbers in parentheses.
Drop is very similar, with a small exception - for obvious reasons we drop the origin string and instead 「打」is noted.
The reason for the game's termination is also recorded as a move.
Game was aborted.
Resignation. The player whose turn it was, is the one who resigned. Time that it took the player to resign can also be noted.
Checkmate or stalemate. The player whose turn it was, is the one who is checkmated.
Losing on time. The player whose turn it was, is the one who ran out of time. Some sites use "Time-up" instead.
Indicates that the immediately preceding move was illegal.
Indicates that the player whose turn this was supposed to be somehow lost by illegality.
Indicates that the player whose it was, declared win by entering king.
On the same line as the move, times might be recorded.
The times are recorded within parentheses separated by "/". The first number is the time spent on that one move in [minute:seconds]. The second number is that player's total time expended thus far in the game in [hours:minutes:seconds].
Either no time, time spent on this move or both times might be recorded.
Each variations starts with 「変化：」 after which is the number of the move we are branching out of. We list the variations in decreasing order of the move number, if the move number is greater than the previous variation number, it means that the previous variation is a parent to this variation - you can see that with variation 6 and variation 4.
Everything after '#' will be ignored by parsers. These comment usually provide some information about when was the file created or what encoding was used.
手数----指手---------消費時間-- # Not mandatory
To comment on moves, start the line with '*', everything after that on the same line is a comment. You can use multiple comments this way.
1 ７六歩(77) ( 0:00/00:00:00)
2 ８四歩(83) ( 0:00/00:00:00)
3 ２六歩(27) ( 3:00/00:03:00)
If you find any mistakes in this text or want to add some additional information, please submit an issue on github.