We build an equilibrium model of a small open economy with labor market frictions and imperfectly enforced regulations. Heterogeneous firms sort into the formal or informal sector. We estimate the model using data from Brazil, and use counterfactual simulations to understand how trade affects economic outcomes in the presence of informality. We show that: (1) Trade openness unambiguously decreases informality in the tradable sector, but has ambiguous effects on aggregate informality. (2) The productivity gains from trade are understated when the informal sector is omitted. (3) Trade openness results in large welfare gains even when informality is repressed. (4) Repressing informality increases productivity, but at the expense of employment and welfare. (5) The effects of trade on wage inequality are reversed when the informal sector is incorporated in the analysis. (6) The informal sector works as an “unemployment," but not a “welfare buffer" in the event of negative economic shocks.