Gram stain is used to classify bacteria based on their forms, sizes, cellular morphologies and color stained by the Gram stain procedure. Gram stain is used for quick evaluation of the specimen and culture material before further testing is performed for infection detection and diagnosis.

Bacteria stain either gram-positive or gram-negative on the basis of differences in their cell wall compositions and architectures. Gram-positive species have a thick peptidoglycan layer and large amounts of teichoic acids; they are unaffected by alcohol decolorization and retain the initial stain, appearing deep violet if their cell walls are undamaged by age, antimicrobial agents, or other factors. Gram-negative species have a single peptidoglycan layer attached to an asymmetric lipopolysaccharide-phospholipid bilayer outer membrane interspersed with protein; the outer membrane is damaged by the alcohol decolorizer, allowing the crystal violet-iodine complex to leak out and be replaced by the counterstain.

Using Gram stain to detect the presence of bacteria and differentiate if an infection is caused by Gram-positive or Gram-negative bacteria often will give enough information to a health provider to initiate treatment with an appropriate antibiotic while waiting for more specific tests, such as a culture, to be completed. In addition, gram stain can detect other elements including white blood cells (WBC), yeast and epithelial cell. Detecting WBC is also important as they are frequently present with a bacterial, parasite or fungal infection.

A Gram stain may also be performed as part of the culture procedure. If bacteria are grown by culture, a Gram stain is performed to help determine the type of bacteria present and to help determine what other tests may need to be performed to definitively identify the cause of infection. Gram stain is the most valuable test for acute infections such as bacterial meningitis and blood cultures as it gives a quick result for initial antibiotic therapy until more testing is obtained.