Skip to main content
lvoer
Participant
March 16, 2019
Question

How to Count Characters in a Line

  • March 16, 2019
  • 4 replies
  • 15798 views

How would you go about counting the number of characters in a line?

"

The door closed slowly

There was no water

"

For example, the first line has 19 characters and the second line has 15 characters.

4 replies

jane-e
Community Expert
Community Expert
March 17, 2019

lvoer  wrote

How would you go about counting the number of characters in a line?

This would be a great feature request and it can be made here:

Adobe Illustrator Feedback

In InDesign you can use the Info panel and click to get a word count of the entire story or select to get a word count of the selection. I would see this working about the same way if it were implemented in Illustrator.

CarlosCanto
Community Expert
Community Expert
March 16, 2019

try the script in this post

Re: word-count in illustrator?

tromboniator
Community Expert
Community Expert
March 17, 2019

Hi, Carlos,

The script isn't working for me with my current configuration:

MacOS 10.14.3

Illustrator 23.0.2

Peter

CarlosCanto
Community Expert
Community Expert
September 8, 2025

Hi Carlos,

The link for the script says it's unreachable. I just wanted to ask if it's still valid. Thanks

Dilara


the original post is gone for good. But here's the script from 2014


// Usage: The script targets all text in a document by default,
//
// press and hold Ctrl/Cmd before running the script to process Selected text frames only

 

#target Illustrator
 
//  script.name = wordCount.jsx;
//  script.description = counts words (and characters including spaces) in the active document
//  script.requirements = an open document with some text
//  script.parent = carlos canto // 08/27/2014
//  script.elegant = false;

// Usage: The script targets all text in a document by default, 
//
//               press and hold Ctrl/Cmd before running the script to process Selected text frames only


function main () {
    try {var idoc = app.activeDocument;}
    catch (e) {alert ('open a document and try again'); return };
    
    var tfObj=idoc.textFrames;
    var wordcount = 0;
    var charcount = 0;
    var linecount = 0;
    
    if(ScriptUI.environment.keyboardState.ctrlKey || ScriptUI.environment.keyboardState.metaKey) { // metaKey = cmd key on a mac
        //alert('ctrl key');
        var sel = idoc.selection;
        tfObj = null;
        tfObj = [];
        for (t=0; t<sel.length; t++) {
            var itext = sel[t];
            if(itext.typename=="TextFrame")
                tfObj.push(itext);
        }
    }

    for (var i=0; i<tfObj.length; i++){
        var tf = tfObj[i]; 

        wordcount += tf.words.length;
        charcount += tf.characters.length; // includes spaces
        linecount += tf.lines.length;
    }

    var helpmsg = '\r\rHelp: \rScript works on all text by default, press & hold \rCtrl/Cmd before launching the script \rto count selected text frames only.';
    alert('Word Count: ' + wordcount + '\rCharacter Count (including spaces): ' + charcount + '\rLine Count: ' + linecount + helpmsg);

} // end main function

main ();

 

 

Jacob Bugge
Community Expert
Community Expert
March 16, 2019

lvoer,

You can also copy each line (or whichever amount of text) into a new word processor document and see it in the File>Properties.

Monika Gause
Community Expert
Community Expert
March 16, 2019

Illustrator doesn't have such a function. So unless there is a script ...

In InDesign you can do this.