Remove redundant tabs for template string const remove = require('removeredundanttabs'); const str = ` Do something. Show some tips if needed. Done. `; console.log(remove(str)); Result Do something. Show some tips if needed. Done.