Get String Length Tool

Just a bit of background, I was working on live data coming through from Java applets into Javascript, there were strings which I had to match, the conditions were like if (thisID === “blahblahblah”) and there were a lot of them, I had to match strings and then do my stuff, the strings were all different, I had to cut each string into sub-strings because there was a variable portion of every string which I didn’t wanted to match. The result you can imagine is that I was sitting there, counting each string character by character and then putting a condition on it. Got the idea of this tool then (obviously I am lazy when it comes to code), just input your string, get the length, put it as a parameter for the Javascript equivalent of PHP substr or maybe use slice() method of JS and move on! Here is tool:

When I actually searched for such a simple tool online to find a string length straight away (like I have seen a simple tool the other day to convert px values in em for CSS), couldn’t find any (maybe there are but I couldn’t find them). However, when you will search you will get lots of functions in every language (C, C++, Java, Javascript etc.) to do that but what if I only want string length and don’t want to write a line, execute it, know the length, erase it and then continue? Well, here is one, it helped me, it may help someone else too!

Happy Coding!

Leave a comment


  1. Hi,

    One of my pet peeves with web sites are the ones that want you to type in text on a form, they tell you there is a max of 200 (or whatever), but do not show the total count of characters as you type. AND THEN when I click on the submit button I get a message that I’ve exceeded the 200 character limit but 1) it doesn’t say by how many characters I’ve typed and/or 2) I have no way of knowing what character/word is AT the 200 character limit in order to make an intelligent decision on where to start deleting characters.

    So here’s my suggestion for an enhancement to this tool: Allow the visitor to your web page to type in a number representing the maximum strength length. If they enter zero, your form above can work as-is. But if they enter a number, when they click on Get String Length, check to see if it exceeds the maximum they’ve typed in AND SHOW the first maximum (like 200) characters of what they typed. It’d be cool if you could show the text below your Enter Text box, and highlight (maybe in red) all text past the maximum number of characters.

    I hope this is understandable. :grin:

  2. Check this collection of string functions online including length

Leave a Reply

[ Ctrl + Enter ]

Get Adobe Flash player