A shearing-to-squeezing transition process for bubble formation in a T-junction was reported using microscopy and digital image technology. The investigations were conducted in a polydimethylsiloxane (PDMS) T-junction. According to the aspect ratio of air slug and bubble generation frequency, the bubbles generated in the microchannel were identified to three types, namely dispersed bubble, short-slug bubble and long-slug bubble. The corresponding modes of bubble formation were identified as shearing, transition and squeezing modes, respectively. Additionally, the microbubble size and generation frequency with various gas pressures and velocity of liquid flows in each mode were investigated. The relevant dimensional arguments were performed to characterize the microbubble formation process in the T-junction. A new scaling law, based on the formation mechanisms, was proposed to predict the size of the microbubbles and showed a good agreement with the experimental results.