The best way to get rid of gnats is to avoid doing things that would attract them to your home or workplace. Never leave your trash cans open. Gnats are attracted to the smell of rotten food, because this is where they eat and lay eggs.
Wash your sink and dry it thoroughly; never leave dirty dishes on it. In addition, see to it that you do not over water your plants. Damp and wet places, when left for a long period of time, become favorite places of insects such as gnats.
You can also set a trap for gnats. Fill a jar with vinegar and cover it. Create several small holes in the jar’s lid. Place it in an area where you find gnats. They will eventually go to the jar, enter it, and will not be able to come out. Make a number of the said traps and place them in other parts of your home.
Another way to get rid of gnats also makes use of vinegar. Put half a cup of vinegar in a container with a wide opening. Add a tablespoon of dish detergent in the vinegar. Place the mixture in the area where you find gnats. You may see that the gnats would go to the mixture, feed on it and die.
If these measures still do not solve your problem, you may use an insect spray in the areas where you normally find many gnats. You should carefully read and follow the instructions indicated in the spray’s container, especially if you own pets. If insect spray does not get rid of the gnats, you may choose to use a fogger.