There are over one million transgender people living in the United States and 33% report negative experiences with a healthcare provider, many of which are connected to data representation in electronic health records (EHRs). We present recommendations and common pitfalls involving sex- and gender-related data collection in EHRs. Our recommendations leverage the needs of patients, medical providers, and researchers to optimize both individual patient experiences and the efficacy and reproducibility of EHR population-based studies. We also briefly discuss adequate additions to the EHR considering name and pronoun usage. We add the disclaimer that these questions are more complex than commonly assumed. We conclude that collaborations between local transgender and gender-diverse persons and medical providers as well as open inclusion of transgender and gender-diverse individuals on terminology and standards boards is crucial to shifting the paradigm in transgender and gender-diverse health.