Scalable quantum computing and communication requires the protection of quantum information from the detrimental effects of decoherence and noise. Previous work tackling this problem has relied on the original circuit model for quantum computing. However, recently a family of entangled resources known as graph states has emerged as a versatile alternative for protecting quantum information. Depending on the graph’s structure, errors can be detected and corrected in an efficient way using measurement-based techniques. Here we report an experimental demonstration of error correction using a graph state code. We use an all-optical setup to encode quantum information into photons representing a fourqubit graph state. We are able to reliably detect errors and correct against qubit loss. The graph we realize is setup independent, thus it could be employed in other physical settings. Our results show that graph state codes are a promising approach for achieving scalable quantum information processing.