The function of NDST2 (N-deacetylase and N-sulfotransferase 2, Ensembl gene identifier ENSG00000166507) is as follows. Essential bifunctional enzyme that catalyzes both the N- deacetylation and the N-sulfation of glucosamine (GlcNAc) of the glycosaminoglycan in heparan sulfate. Modifies the GlcNAc-GlcA disaccharide repeating sugar backbone to make N-sulfated heparosan, a prerequisite substrate for later modifications in heparin biosynthesis. Plays a role in determining the extent and pattern of sulfation of heparan sulfate. Required for the exosomal release of SDCBP, CD63 and syndecan (PubMed:22660413). {ECO:0000269|PubMed:10758005, ECO:0000269|PubMed:12634318, ECO:0000269|PubMed:16343444, ECO:0000269|PubMed:22660413}.