Streptococcus agalactiae, a colonizing agent in pregnant women and the main cause of neonatal sepsis and meningitis, has been increasingly associated with invasive disease in nonpregnant adults. We collected a total of 87 non-repetitive S. agalactiae isolates causing community-acquired (CA) and hospital-acquired (HA) infections in nonpregnant adults from a teaching hospital in Shanghai between 2009 and 2013. We identified and characterized their antibiotic resistance, sequence type (ST), serotype, virulence, and biofilm formation. The most frequent STs were ST19 (29.9%), ST23 (16.1%), ST12 (13.8%), and ST1 (12.6%). ST19 had significantly different distributions between CA- and HA-group B Streptococci (GBS) isolates. The most frequent serotypes were III (32.2%), Ia (26.4%), V (14.9%), Ib (13.8%), and II (5.7%). Serotype III/ST19 was significantly associated with levofloxacin resistance in all isoates. The HA-GBS multidrug resistant rate was much higher than that of CA-GBS. Virulence genes pavA, cfb were found in all isolates. Strong correlations exist between serotype Ib (CA and HA) and surface protein genes spb1 and bac, serotype III (HA) and surface protein gene cps and GBS pilus cluster. The serotype, epidemic clone, PFGE-based genotype, and virulence gene are closely related between CA-GBS and HA-GBS, and certain serotypes and clone types were significantly associated with antibiotic resistance. However, CA-GBS and HA-GBS still had significant differences in their distribution of clone types, antibiotic resistance, and specific virulence genes, which may provide a basis for infection control.