If you enter text in the text box above and click the "Convert Text to Morse Code" button, it will do precisely that. It will also work in reverse and convert Morse Code to text.
In the output, I have set it to use vertical bars (|) to represent dashes and apostrophes (') to represent dots, as I found it was clearer where the spaces were than when I used hyphens (-) and full stops (.). The input section will allow you to use either approach, so if you prefer to use (.--.) notation rather than ('||'), it will work.
The gap between letters is represented by a space and the gap between words is represented by a tilde (~).