Highly multiplexed single-molecule FISH has emerged as a promising approach to spatially resolved single-cell transcriptomics because of its ability to directly image and profile numerous RNA species in their native cellular context. However, background-from off-target binding of FISH probes and cellular autofluorescence-can become limiting in a number of important applications, such as increasing the degree of multiplexing, imaging shorter RNAs, and imaging tissue samples. Here, we developed a sample clearing approach for FISH measurements. We identified off-target binding of FISH probes to cellular components other than RNA, such as proteins, as a major source of background. To remove this source of background, we embedded samples in polyacrylamide, anchored RNAs to this polyacrylamide matrix, and cleared cellular proteins and lipids, which are also sources of autofluorescence. To demonstrate the efficacy of this approach, we measured the copy number of 130 RNA species in cleared samples using multiplexed error-robust FISH (MERFISH). We observed a reduction both in the background because of off-target probe binding and in the cellular autofluorescence without detectable loss in RNA. This process led to an improved detection efficiency and detection limit of MERFISH, and an increased measurement throughput via extension of MERFISH into four color channels. We further demonstrated MERFISH measurements of complex tissue samples from the mouse brain using this matrix-imprinting and -clearing approach. We envision that this method will improve the performance of a wide range of in situ hybridization-based techniques in both cell culture and tissues.