You asked:

is 5 g larger than 508 mg

Yes. 5 grams is greater than 508 milligrams.