Taking a hardhearted stance with

(こころ)(おに)にする means forcing yourself to act sternly even though you feel sympathy for the person affected.

Literal Meaning

This expression literally translates as “to turn one’s heart into an ogre”.

Usage Notes

The speaker suppresses compassion to do something they believe is necessary but harsh. A parent might use the expression before disciplining a child even though the punishment pains them.

It can also describe being strict with yourself. In either case, the point is the conflict between sympathy and a deliberate decision to stay firm.

Dictionary Definition

かわいそうだと(おも)いながら、(きび)しい態度(たいど)をとる。

To take a harsh attitude (with someone) while feeling sorry (for them).

Goo Dictionary

Further Reading

Examples

Being strict about eating sweets with 心を鬼にする

Learn the meaning and usage of the idiom 心を鬼にする in Japanese, with examples from manga.
好きな子がめがねを忘れた » Volume 2 » Page 119

Having gained weight recently, Mie asks Komura to stop her from eating sweets at school, a difficult task as it’s White Day. Komura repeatedly stops Mie from eating the cookies and chocolate she’s received as gifts. His resolve weakens as he finds it adorable how Mie tries to sneak a bite whenever he’s not looking.

小村(こむら):
「で…でもダメだ! 三重(みえ)さんが一度(いちど)()めたことを(やぶ)らせては… (こころ)(おに)にしないと…!!」
“But, that's no good! If I let Mie break her decision... I have to be strict for her sake!”

Being strict with oneself and one's student with 心を鬼にする

Learn the meaning and usage of the idiom 心を鬼にする in Japanese, with examples from manga.
名探偵コナン » Volume 16 » Page 91

Conan’s classmates aren’t fond of their new teacher’s strict attitude. Ms. Kobayashi explains how at her last school, she couldn’t bring herself to be strict, and it allowed her students to get so out of control that students were injured in a fight.

小林(こばやし):
「だから、この学校(がっこう)では二度(にど)とあんな(こと)()(かえ)すまいと…」
“Therefore, to keep from repeating that kind of situation at this school...”
(こころ)(おに)にして自分(じぶん)にも生徒(せいと)にも(きび)しくしてきたの…」
“I hardened my heart and became strict, with myself and with my students...”

Club training with 心を鬼にする

Learn the meaning and usage of the idiom 心を鬼にする in Japanese, with examples from manga.
桜蘭高校ホスト部 » Volume 1 » Page 127

Renge wedges herself into the Ouran High School Host club, appointing herself the club’s manager. Due to her social status, Tamaki and the other wealthy club members are unable to object. Instead, they leave it to Haruhi to oust her.

(たまき):
「これもホスト修行(しゅぎょう)だハルヒ!!」
“This, too, is host training, Haruhi!!”
「おとーさんは(こころ)()ににするぞ!!」
“Dad has to harden his heart!”