An image forming apparatus comprising: an apparatus main body including an ejecting part configured to eject a sheet, on which an image is formed, toward an ejecting space; a post-processing device configured to be slidable at the ejecting space between an attached position to be adjacent to the ejecting part and a detached position to be more remote from the ejecting part than the attached position; a first magnetic body arranged at the post-processing device; and a second magnetic body arranged at the apparatus main body so as to face the first magnetic body in a state where the post-processing device is shifted to the detached position, wherein the post-processing device includes: a post-processing part configured to perform post-processing to the sheet on which the image is formed; and a movable guide configured to compose a conveying path which communicates the ejecting part and the post-processing part, and the movable guide is configured to be movable between an ordinary position to compose the conveying path and an opening position to open the conveying path, and the first magnetic body is configured to magnetically attract the second magnetic body so as to hold the movable guide at the opening position, in the state where the post-processing device is shifted to the detached position, and the first magnetic body is configured to separate from the second magnetic body and to release magnetic attraction to the second magnetic body when the post-processing device slides from the detached position to the attached position. an apparatus main body including an ejecting part configured to eject a sheet, on which an image is formed, toward an ejecting space; a post-processing device configured to be slidable at the ejecting space between an attached position to be adjacent to the ejecting part and a detached position to be more remote from the ejecting part than the attached position; a first magnetic body arranged at the post-processing device; and a second magnetic body arranged at the apparatus main body so as to face the first magnetic body in a state where the post-processing device is shifted to the detached position, wherein the post-processing device includes: a post-processing part configured to perform post-processing to the sheet on which the image is formed; and a movable guide configured to compose a conveying path which communicates the ejecting part and the post-processing part, and the movable guide is configured to be movable between an ordinary position to compose the conveying path and an opening position to open the conveying path, and the first magnetic body is configured to magnetically attract the second magnetic body so as to hold the movable guide at the opening position, in the state where the post-processing device is shifted to the detached position, and the first magnetic body is configured to separate from the second magnetic body and to release magnetic attraction to the second magnetic body when the post-processing device slides from the detached position to the attached position. a post-processing part configured to perform post-processing to the sheet on which the image is formed; and a movable guide configured to compose a conveying path which communicates the ejecting part and the post-processing part, and the movable guide is configured to be movable between an ordinary position to compose the conveying path and an opening position to open the conveying path, and the first magnetic body is configured to magnetically attract the second magnetic body so as to hold the movable guide at the opening position, in the state where the post-processing device is shifted to the detached position, and the first magnetic body is configured to separate from the second magnetic body and to release magnetic attraction to the second magnetic body when the post-processing device slides from the detached position to the attached position.