In this paper, we study how legal uncertainty affects economic activity. We develop a parsimonious model with different types of legal uncertainty that reduce economic activity and that can be classified as idiosyncratic (i.e., diversifiable) or systematic (i.e., nondiversifiable). We test the model’s predictions using micro-level data on bankruptcy judges and corporate loans from Korea. Exploiting differences in judges’ debtor-friendliness combined with random judge assignment to restructuring cases and exogenous judge rotations in the judicial system, we compute time-varying court-level measures of debtor-friendliness and legal uncertainty. We first document that firms are more likely to file for restructuring in more debtor-friendly courts with lower legal uncertainty. We further show that legal uncertainty reduces the size of credit markets. The effects are driven by high-risk firms that are most sensitive to bankruptcy law. Examining interest rates, we find that credit supply is relatively more sensitive to systematic than to idiosyncratic sources of legal uncertainty relative to credit demand.