Boosting smallholder food production can potentially improve children’s nutrition in rural Sub-Saharan Africa through a production-own consumption pathway and an income-food purchase pathway. Rigorously designed studies are needed to provide evidence for nutrition impact, but are often difficult to implement in agricultural projects. Within the framework of a large agricultural development project supporting legume production (N2Africa), we studied the potential to improve children’s dietary diversity by comparing N2Africa and non-N2Africa households in a cross-sectional quasi-experimental design, followed by structural equation modelling (SEM) and focus group discussions in rural Ghana and Kenya. Comparing N2Africa and non-N2Africa households, we found that participating in N2Africa was not associated with improved dietary diversity of children. However, for soybean, SEM indicated a relatively good fit to the posteriori model in Kenya but not in Ghana, and in Kenya only the production-own consumption pathway was fully supported, with no effect through the income-food purchase pathway. Results are possibly related to differences in the food environment between the two countries, related to attribution of positive characteristics to soybean, the variety of local soybean-based dishes, being a new crop or not, women’s involvement in soybean cultivation, the presence of markets, and being treated as a food or cash crop. These findings confirm the importance of the food environment for translation of enhanced crop production into improved human nutrition. This study also shows that in a situation where rigorous study designs cannot be implemented, SEM is a useful option to analyse whether agriculture projects have the potential to improve nutrition.