We report two experimental studies testing how a cognitive feeling of similarity affects dishonesty in individual and collaborative tasks when cheating hurts others. By employing a novel die-in-the-box paradigm with a total of 1080 subjects, we find that a sense of similarity (vs. dissimilarity) tends to increase dishonesty in settings highlighting the relationship with a collaborator, but tends to decrease dishonesty in settings highlighting the relationship with others who suffer from cheating. Corroborating these results, a code of conduct highlighting similarity towards the firm’s employees leads to higher levels of cheating than a code of conduct highlighting similarity towards other members of the society. The results provide insights into how to craft effective organizational codes of ethical conduct.