Collaborations among nearly zero energy buildings (nZEBs) (e.g. renewable energy sharing) can improve nZEBs’ performance at the community level. To enable such collaborations, the nZEBs need to be properly grouped. Grouping nZEBs with similar energy characteristics merely brings limited benefits due to limited collaboration existed, while grouping nZEBs with diverse energy characteristics can bring more benefits. In the planning of nZEB communities, due to the large diversity of energy characteristics and computation complexity, proper grouping that maximizes the collaboration benefits is difficult, and such a grouping method is still lacking. Therefore, this paper proposes a clustering based grouping method to improve nZEB performance. Using the field data, the grouping method first identifies the representative energy characteristics by advanced clustering algorithms. Then, it searches the optimal grouping alternative of these representative profiles that has the optimal performance. For validation, the proposed grouping method is compared with two cases (the nZEBs are either not grouped or randomly grouped) in aspects of economic costs and grid interaction. The study results demonstrate that the proposed method can effectively improve nZEBs’ performances at the community level. The propose method can provide the decision makers a means to group nZEBs, which maximize the collaboration benefits and thus assists the planning of nZEB communities.