How to stop xss payload?

<script>alert(‘XSS’)< /script>

these gets gets stored in database. how to deal with these?

Do a sanatize the content before output