In this paper, we study how legal uncertainty affects economic activity. We develop a par- simonious model that generates different types of legal uncertainty, which reduce economic activity and which can be classified as idiosyncratic (i.e., diversifiable) or systematic (i.e., non- diversifiable). We test the prediction of the model using micro-level data on bankruptcy judges and corporate loans from Korea. Exploiting differences in judges’ debtor-friendliness com- bined 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 sen- sitive to bankruptcy law. On 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.