The present study was aimed at investigating the effects of sodium butyrate and sodium β-hydroxybutyrate on lactation and health of dairy cows fed a high-concentrate (HC) diet. Eighty mid-lactation dairy cows with an average milk yield of 33.75 ± 5.22 kg/d were randomly allocated to four groups (n = 20 per group) and were fed either a low-concentrate (LC) diet, a HC diet, the HC diet with 1% sodium butyrate (HCSB), or the HC diet with 1% sodium β-hydroxybutyrate (HCHB). The feeding trial lasted for 7 weeks, with a 2-week adaptation period and a 5-week measurement period, and the trial started from 96 ± 13 d in milk. Sodium butyrate supplementation delayed the decline in milk production and improved milk synthesis efficiency and milk fat content. Additionally, it decreased the proinflammatory cytokines and acute phase proteins (APPs) in plasma, the leucocytes in blood, the somatic cell count (SCC) in milk, and the gene expression of pattern recognition receptors (PRRs) and proinflammatory cytokines in the mammary gland, due to decreasing the contents of bacterial cell wall components (lipopolysaccharide, LPS; peptidoglycan, PGN; and lipoteichoic acid, LTA) in the rumen and plasma, compared with the HC diet. Sodium β-hydroxybutyrate supplementation also improved milk yield, milk synthesis efficiency and milk fat content and partially reduced the adverse effects caused by the HC diet, but it had no effect on decreasing bacterial cell wall components in the rumen and plasma, compared with the HC diet. Collectively, both sodium butyrate and sodium β-hydroxybutyrate mitigated the negative effects of HC diet on lactation and health of dairy cows, with sodium butyrate being more effective than sodium β-hydroxybutyrate.