Exosomes and other small extracellular vesicles (sEVs) provide a unique mode of cell-to-cell communication in which microRNAs (miRNAs) produced and released from one cell are taken up by cells at a distance where they can enact changes in gene expression1–3. However, the mechanism by which miRNAs are sorted into exosomes/sEVs or retained in cells remains largely unknown. Here we demonstrate that miRNAs possess sorting sequences that determine their secretion in sEVs (EXOmotifs) or cellular retention (CELLmotifs) and that different cell types, including white and brown adipocytes, endothelium, liver and muscle, make preferential use of specific sorting sequences, thus defining the sEV miRNA profile of that cell type. Insertion or deletion of these CELLmotifs or EXOmotifs in a miRNA increases or decreases retention in the cell of production or secretion into exosomes/sEVs. Two RNA-binding proteins, Alyref and Fus, are involved in the export of miRNAs carrying one of the strongest EXOmotifs, CGGGAG. Increased miRNA delivery mediated by EXOmotifs leads to enhanced inhibition of target genes in distant cells. Thus, this miRNA code not only provides important insights that link circulating exosomal miRNAs to tissues of origin, but also provides an approach for improved targeting in RNA-mediated therapies. MicroRNAs encode sorting sequences that determine whether they are secreted in exosomal vesicles to regulate gene expression in distant cells or retained in cells that produced them, with different sequences used by individual cell types.