Score-based generative models are a novel class of generative models that have shown state-of-the-art sample quality in image synthesis, surpassing the performance of GANs in multiple tasks. Here we present ProteinSGM, a score-based generative model that produces realistic de novo proteins and can inpaint plausible backbones and functional sites into structures of predefined length. With unconditional generation, we show that score-based generative models can generate native-like protein structures, surpassing the performance of previously reported generative models. We apply conditional generation to de novo protein design by formulating it as an image inpainting problem, allowing precise and modular design of protein structure.