Cells in vivo are often subject to the challenge of spatial confinement from neighboring cells and extracellular matrix (ECM) that are usually adhesive and deformable. Here, we showed that confinement makes initially quiescent round cells on soft adhesive substrates spread and migrate, exhibiting a phenotype similar to that of cells on unconfined stiff substrates. Interestingly, the confinement-induced cell spreading and migration exist widely in many cell types, and depend on formins, cell contractility and endonuclear YAP-TEAD interaction. Finally, we demonstrated the nucleus is a mechanosensor independent of ECM rigidity, and its flattening alone is sufficient to trigger YAP nuclear translocation, assembly of focal adhesions and stress fibers, cell spreading and migration. Thus, our findings revealed a new inside-out mechanism through which the nucleus directly detects and responds to external mechanical confinement, and could have important implications for cell migration in crowded micro-environments during cancer metastasis, wound healing and embryonic development.