Electricity demand is rising in lockstep with global population growth. The present power system, which is almost a century old, faces numerous issues in maintaining a steady supply of electricity from huge power plants to customers. To meet these issues, the electricity industry has enthusiastically embraced the new smart grid concept proposed by engineers. If we can provide a secure smart grid, this movement will be more useful and sustainable. Machine learning, which is a relatively recent era of information technology, has the potential to make smart grids extremely safe. This paper is a literature survey of the application of machine learning in different areas of smartgrids. This paper concludes by mentioning the best machine learning algorithms that can be used in different aspects of the smart grid.