How do you clean an egr valve?

Depends on the EGR valve. A good lot of them can be cleaned and reused. New ones can costs hundreds of dollars.

The EGR valve works by routing a small amount of the exhaust gases back into the combustion chamber.

See the Related link for more information.
To clean the EGR valve, you may be required to remove the vacuum hose and clean out the carbon deposits.