SAP97 interacts with AMPA receptors (AMPARs) and NMDA receptors (NMDARs) during sorting and trafficking to synapses. Here we addressed how SAP97 distinguishes between AMPARs and NMDARs and what role the adaptor/scaffold protein, CASK, plays in the process. Using intramolecular SAP97 Förster resonance energy transfer sensors, we demonstrated that SAP97 is in "extended" or "compact" conformations in vivo. SAP97 conformation was regulated by a direct interaction between SAP97 and CASK through L27 protein-interaction domains on each protein. Unbound SAP97 was mostly in the compact conformation, while CASK binding stabilized it in an extended conformation. In HEK cells and rat hippocampal neurons, SAP97 in the compact conformation preferentially associated and colocalized with GluA1-containing AMPARs, and in the extended conformation colocalized with GluN2B-containing NMDARs. Altogether, our findings suggest a molecular mechanism by which CASK binding regulates SAP97 conformation and its subsequent sorting and synaptic targeting of AMPARs and NMDARs during trafficking to synapses.