Convert text to ASCII art on Linux Terminal

Endrit Qerreti

Endrit Qerreti

In this tutorial, you will learn how to convert normal tex to ASCII art on your terminal on Linux.

There are many apps on Linux that use ASCII art to display the app name on the terminal, or some other type of information, I think displaying the name of the app in ascii is the most common use of ascii art in command line apps.

You can generate the ASCII art using an online third party service, and then just displaying it on terminal. However, in this tutorial, we are going to show you how to generate ascii art by using an app called figlet.

Step 1 - Install figlet

figlet is the name of the app that we'll be using to generate ASCII art. This app allows you to convert your normal text to ascii. You can also integrate this package on your existing projects, for example let's say you want to display some ascii art on your app, instead of doing it manually you can use figlet.

sudo apt install figlet

Step 2 - Verify

Once figlet has been installed on your system, run the version command to verify that it got installed without any issues.

figlet -v

Output

FIGlet Copyright (C) 1991-2012 Glenn Chappell, Ian Chai, John Cowan,
Christiaan Keet and Claudio Matsuoka
Internet: <info@figlet.org> Version: 2.2.5, date: 31 May 2012

FIGlet, along with the various FIGlet fonts and documentation, may be
freely copied and distributed.

If you use FIGlet, please send an e-mail message to <info@figlet.org>.

The latest version of FIGlet is available from the web site,
	http://www.figlet.org/

Usage: figlet [ -cklnoprstvxDELNRSWX ] [ -d fontdirectory ]
              [ -f fontfile ] [ -m smushmode ] [ -w outputwidth ]
              [ -C controlfile ] [ -I infocode ] [ message ]

💡
This means figlet is installed on your system, and you can use it. 

Step 3 - Use figlet

In the examples below, we are going to show you how to print text to ascii, and align this text to the left or right, and also how to save the ascii text to a text file.

The default command to print text without any arguments

figlet text

So simply replace text with your text and it will be converted into ASCII

For example, we are going to convert OwlHowTo to ASCII

figlet OwlHowTo

Align the printed ASCII to center

figlet -c OwlHowTo

Align text to the left

figlet -l OwlHowTo

Alight text to the right

figlet -r OwlHowTo

Save ASCII to a text file

figlet OwlHowTo > myfile.txt

And the generated ascii text will be saved on myfile.txt but it won't be displayed in the terminal, if you want to do both, save the ascii text and display the text on terminal you can use the cat command, for example

figlet OwlHowTo > myfile.txt && cat myfile.txt

Now text will be saved to myfile and also displayed in the terminal at the same time.

💡
We showed just some examples of how to print and align text to different positions. To get the full list of commands, that you can use on figlet you can either read the manual page on the terminal by running man figlet or by simply reading the official documentation on their website here

Conclusion

In this tutorial, we explained how to convert normal text to ASCII on your terminal by using an app called figlet. Even though figlet is old, it still does a great job when it comes to printing ascii art on Linux.