JSFiddle - React, Tailwind, and code Playground
HTML
<input type="text" id="separator" value="Doesnt\nwork" />
<input type="button" id="button" value="submit" />
JavaScript
document.getElementById('button').onclick = function(){
alert(document.getElementById('separator').value.replace('\\n', '\n'));
alert("This\nworks");
};