What should I eat before a 5k race or run?

You will probably run your 5k in less than 40 minutes. Even at 40 minutes your body will have ample energy already stored up. You do not need anything special before a race.

Carbohydrates take about 30 minutes to kick in so it’s not worth eating those, your body will already have an ample carbohydrate store. You are just consuming more weight and that will slow you down.

So NO pasta the night before, if anything it will slow you down.

A very light breakfast of what you normally eat 2 hours before you run will be fine.

I find that a banana and some caffeine (in the form of a strong not too milky coffee) are best for me.

After the race you will need to rehydrate with about 500ml of fluid and if you are being super efficient you will have a little bit of protein within 30 minutes of finishing. Both of which help your body recover.