Studies focusing on marine macrophyte metabarcoding from environmental samples are scarce, due to the lack of a universal barcode for these taxa, and to their poor representation in DNA databases. Here, we searched for a short barcode able to identify marine macrophytes from tissue samples; then, we created a DNA reference library which was used to identify macrophytes in eDNA from coastal sediments. Barcoding of seagrasses, mangroves and marine macroalgae (Chlorophyta, Rhodophyta and Phaeophyceae) was tested using 18 primer pairs from six barcoding genes: the plant barcodes rbcL, matK and trnL, plus the genes ITS2, COI and 18S. The 18S gene showed the highest universality among marine macrophytes, amplifying 95-100% of samples; amplification performance of the other barcodes was limited. Taxonomy was assigned using a phylogeny-based approach to create an 18S DNA reference library. Macrophyte tissue sequences were accurately identified within their phyla (88%), order (76%), genus (71%) and species (23%). Nevertheless, out of 86 macrophytes tested, only 48% and 15% had a reference sequence at genus and at species level, respectively. Identification at these levels can be improved by more inclusive reference libraries. Using the 18S mini-barcode and the reference library, we recovered eDNA from 21 marine macrophytes in sediments, demonstrating the barcode's ability to trace primary producers that contribute to blue carbon. We expect this barcode to also be useful for other ecological questions, such as tracing macro primary producers in marine food webs.