It is the first time that a female would-be suicide bomber has been convicted.
Dian Yulia Novi, 28, was arrested in December last year after police uncovered her plan to blow herself up outside Jakarta’s Presidential Palace during the changing of the guard.
A panel of three judges at the East Jakarta District Court found her guilty of charges including evil conspiracy and attempted terrorism.
The prosecutors in the case had demanded she be jailed for 10 years but the woman’s lawyers said her sentence was reduced because she admitted her actions.
The woman is due to give birth next week.
The indictment tended in the court showed she was living in Taiwan when she learned about Jihad and the Islamic State group on social media.
In early December 2016, she rented a room in a house in Jakarta along with three other defendants and bought a pressure cooker online, the indictment showed.
Police later found and detonated the explosives in the same room.
She was arrested the day before the attack was to take place.