Density is the ratio of mass to volume, i.e. D = M / V, then the dimenssions of densitty are [D] = [Mass] / [Volume]. The dimenssions of volume are [volume] =[lengh]^3. Then, [D] = [mass] / [length] ^ 3. So, you can have g / cm^3 , kg / m^3, kg / liter, or any that relates a unit of mass with a unit of volume.