Skip to Content
ScriptsExamplesShow Text Stats

Show Text Stats

Show text statistics from input.

Download show-text-stats.js
show-text-stats.js
/* @okjson.schemaVersion 1 @okjson.name Show Text Stats @okjson.description Show number of lines, total words, and total characters. @okjson.icon paragraphsign @okjson.openResultInNewWindow no @okjson.preprocessInput no @okjson.author OK JSON @okjson.authorURL https://okjson.app */ function main(string) { let lines = $text.countLines(string); let words = $text.countWords(string); let characters = $text.countCharacters(string); $alert.info('Text Stats', `${lines} lines · ${words} words · ${characters} characters`); return ''; }

Example

I’ve seen things you people wouldn’t believe. Attack ships on fire off the shoulder of Orion. I watched C-beams glitter in the dark near the Tannhäuser Gate. All those moments will be lost in time, like tears in rain. Time to die.

The result should be 1 lines · 42 words · 230 characters.