Background: Little is known about the associations between human leukocyte antigens (HLAs) and food allergies. Our aim was to analyze the associations between the HLA class II polymorphism and food allergy using bioinformatics. Methods: A two-step algorithm was developed which mimics the food allergen processing in the human body. In the first step, the allergen is digested by pepsin, trypsin and chymotrypsin. In the second step, the digested fragments bind to the most frequent 12 HLA-DRB1 and 5 HLA-DQ alleles, and the binding affinities are predicted. Results: The algorithm was applied to 13 well-known milk and egg allergens. The predicted HLA binders were compared to known T-cell and IgE epitopes originating from the same allergens, and 77% of them were found to overlap. We found that the peptides generated from milk allergens bind to DRB1*01:01, DQ7 and DQ8 but not to DRB1*03:01, DRB1*04:04, DRB1*12:01 and DRB1*15:01. The peptides generated from egg allergens bind to DRB1*01:01, DQ4, DQ7 and DQ8 but not to DRB1*03:01, DRB1*04:04 and DRB1*12:01. They bind to all the DQs studied. The alleles that bind to allergen peptides could be considered as susceptible to the particular allergy and the nonbinding alleles as protective. Conclusions: The alleles DRB1*01:01, DQ7 and DQ8 are considered as susceptible to cow's milk allergy and DRB1*03:01, DRB1*04:04, DRB1*12:01 and DRB1*15:01 as protective. The alleles DRB1*01:01, DQ4, DQ7 and DQ8 are considered as susceptible to egg allergy and DRB1*03:01, DRB1*04:04 and DRB1*12:01 as protective. Protective DQs against egg allergy were not revealed in this study.