Automatic bug repair as the last step in program repair has attracted a lot of research attention. Various ideas and techniques have been presented in this feld. Recent bug fxing techniques use machine learning and graphs to generate fxes. Despite the promising results of recent approaches, maintaining high speed and accuracy as well as recording a wide range of errors may still be a problem. In this paper, a new approach is presented in the feld of automatic bug fxing based on graphs and model checking. For this purpose, we have used the graph transformation and model checking system to create a sequence of edits and produce fxes. Then, using meta-heuristic algorithms, we have selected the best solution and fx from the generated solutions. We use the extracted graphs from the buggy JavaScript code and their corresponding bug-free ones. In evaluating the efectiveness of the proposed method, we implement it in GROOVE, which is a toolbox used to design and check graph transformation systems. Experimental results on identical dataset demonstrate that the proposed method outperforms other related methods in generating fxes. Also, this method covers a wider range of bugs compared to previous methods.