In J. R. R. Tolkien's The Hobbit published in 1937 on the very first pages we can find two elements which can be considered as Freemason-related. First is this fragment:
"Gandalf, Gandalf! Good gracious me! Not the wandering wizard that gave Old Took a pair of magic diamond studs that fastened themselves and never came undone till ordered? Not the fellow who used to tell such wonderful tales at parties, about dragons and goblins and giants and the rescue of princesses and the unexpected luck of widows' sons?"
The Widow's Son in Freemasonic symbolism applies to Hiram, the architect of the Salomon Temple and his mystery is a part of the Freemasonic initiation.
The second element is this drawing of Bag End by J. R. R. Tolkien:
Which has some elements which can be found in a typical Freemasonic lodge:
Coincidence? Yes, rather coincidence. J. R. R. Tolkien was a devout Roman Catholic and from his biography, writings, letters and his friends' memories we can be sure that he could not be a Freemason.
On the other hand some members of his family were Freemasons in London and Birmingham (see here). Maybe Professor Tolkien was highly knowledgable about the masons, and their symbols and left some phrases and pictures to play with Freemasonic members of the Tolkien family. And maybe he even tried to treat the Freemasonic beliefs as he treated the Pagan ones – he wanted to "Christianize" them, to find deep Christian meaning in all human beliefs and myths...?