One milligram per litre is exactly 0.001 grams per litre. Both express mass concentration — how much of a substance is dissolved in a given volume — and the prefix is chosen to keep the figure readable rather than for any physical reason.
About the units
Mass concentration is the mass of a solute divided by the volume of solution. Grams per litre suits concentrated solutions: sugar in a syrup, salt in brine, protein in a culture medium. Milligrams per litre suits dilute ones, which covers most of analytical chemistry and all of water quality work. For dilute aqueous solutions, milligrams per litre is numerically equal to parts per million, because a litre of water weighs a kilogram — a coincidence that holds only for water and only while the solution is dilute enough that its density stays close to water's.
The exact factor
The factor is exactly 1,000. Reference values: the EU drinking water limit for chloride is 250 mg/l and for nitrate 50 mg/l; seawater salinity is about 35 g/l; and a physiological saline solution is 9 g/l. Note that micrograms per litre takes over below one milligram, and that is where most pesticide and pharmaceutical residue limits sit — the EU limit for lead in drinking water is being lowered to 5 µg/l, which is 0.005 mg/l, under the 2020 drinking water directive — member states may keep the old limit of 10 µg/l during a transition that runs to January 2036.
Where you meet this conversion
Water quality, analytical chemistry and biotechnology. Drinking water regulations set limits in milligrams or micrograms per litre for every regulated substance. Fermentation and cell culture media are specified in grams per litre for major components and milligrams for trace nutrients. Environmental discharge permits use both. Laboratory reports state results in whichever unit keeps the value between one and a thousand, so the same substance may appear in different units on consecutive pages of one report.