David Gallacher, 37, of no fixed address, attacked Samsam Haji-Ali, 34, and her husband outside a Co-op in Bletchley, Buckinghamshire, in August.
He admitted actual bodily harm, assault by beating and two counts of racially or religiously aggravated assault.
The judge called him a "thug and a racist to boot."
Aylesbury Crown Court heard Somali Ms Haji-Ali was racially abused by Gallacher in the Water Eaton Road shop on 4 August.
He swore at her and said: "You come here with your clown outfit on..."
More news from Buckinghamshire
As her husband Abdullah Sulamain, 40, attempted to calm him down in the car park outside, Gallacher hit him on the head with a bottle of wine and a bag of ice.
He then kicked Ms Haji-Ali in the stomach.
Judge Francis Sheridan said: "She told him she was pregnant and he continued to kick her again, after he was told she was pregnant.
"She is left rolling around on the ground in agony and later found there is bleeding, before she lost the baby."
Ms Haji-Ali miscarried on 24 August.
Judge Sheridan said her pregnancy had been "absolutely fine" before the attack, and in his view "the loss of that baby was a direct result of a kick to the stomach of a pregnant woman".
He told Gallacher: "There was a racial element to this attack.
"The defendant is a shabby racist on the language that he used towards this lady.
"It is time you learnt that your vile conduct and abhorrent views are a thing of the past."
Gallacher admitted two counts of racially aggravated assault occasioning actual bodily harm and three counts of assaulting a police officer during his arrest in September last year.
He was jailed for three years and seven months for the race attacks and four months for the officer assault, to run consecutively.
A "shabby racist" who repeatedly kicked a pregnant Muslim woman, resulting in her losing her unborn baby, has been jailed for almost four years.