Is there anyone to help me with making a peace of code for this thing

Hello im trying to make a code editor, (i want to make a text field so than whenn i chose html/code and than paste my code in there that to turn the code in text like this if anyone can help me thanks i only need that peace of code for only the code part (from code to text).

What are you using to make your editor?
It’s a good idea to tell people which language you’re using so the right people can help you.