JSFiddle - React, Tailwind, and code Playground JavaScript var str = 'c:\blah\di\blah' str = str.replace(/\\/, "\\\\"); alert('' + str)