The 16 and 17-year-old entered a flat in the old town area of Scarborough and stole cash, a safe and a purse.
One of the youths carried a bread knife which he used to threaten the woman at the property.
Police tracked them down and arrested them on the same day – 27 October 2018.
The victim and her unborn baby were unharmed but she was extremely distressed by the incident.
The boys, who are both from Scarborough but cannot be named due to court reporting restrictions, were interviewed by officers and charged with aggravated burglary with intent.
They were sentenced to three years, eight months in a young offenders’ institution by a judge at York Crown Court on Tuesday after pleading guilty.
Following the sentence, Detective Constable Rachael Hughes who led the investigation for Scarborough CID, said: “This was a horrific knifepoint robbery against a pregnant woman. What makes this incident even more alarming is the age of the defendants, the youngest of which is just 16.
“Fortunately though, they were very quickly tracked down within hours of the incident after they were recognised by a neighbourhood policing office and detained.
“The victim and other residents can rest assured that these offenders will be off the streets of Scarborough for some time while they serve custodial sentences.”