Reverse Words




The simple online word reverser tool takes text that you enter and reverses the words, but keeps the letters in each word in the same order. For example, if you enter Hello how are you it would convert to you are how Hello.

Honestly, not sure what you would use this for but it was a short little snippet of JavaScript to write so I included it here.

How to use

You can either type in the text area under input or paste text into it. Either way the page will automatically take whatever you put in and reverse the sentence.

The Script

Sure, if you really wanted to see the JavaScript that makes this word reverser work it would be easy enough just to view source. But, I'll save you a step. Here it is.

let text = document.getElementById('text').value.trim();
let rev = text.split(/\s+/).reverse().join(' ');
document.getElementById('results').innerText = rev;

That's it. Just three lines, plus a couple of extra to attach that to event listeners so the output updates automatically as you type or paste in text.

DigitalOcean Referral Badge

This website may contain affiliate links. If you click on an affiliate link and make a purchase, we may receive a small commission at no additional cost to you.