___________.___ ________.__ __ __ /\ __
\_ _____/| |/ _____/| | _____/ |_ |__| ______ / / _/ |_ ______
| __) | / \ ___| | _/ __ \ __\ | |/ ___/ / / \ __\/ ___/
| \ | \ \_\ \ |_\ ___/| | | |\___ \ / / | | \___ \
\___ / |___|\______ /____/\___ >__| /\ /\__| /____ > / / |__| /____ >
\/ \/ \/ \/ \______| \/ \/ \/
This project aims to fully implement the FIGfont spec in TypeScript (compiles to JavaScript). It works in the browser and with Node. You can see it in action here: http://patorjk.com/software/taag/ (this project was written to power that application)
Install:
npm install figlet
Simple usage:
import figlet from "figlet";
async function doStuff() {
const text = await figlet.text("Hello World!!");
console.log(text);
}
doStuff();
Or the classic callback version:
const figlet = require('figlet');
figlet("Hello World!!", function (err, data) {
if (err) {
console.log("Something went wrong...");
console.dir(err);
return;
}
console.log(data);
});
These will print out:
_ _ _ _ __ __ _ _ _ _
| | | | ___| | | ___ \ \ / /__ _ __| | __| | | |
| |_| |/ _ \ | |/ _ \ \ \ /\ / / _ \| '__| |/ _` | | |
| _ | __/ | | (_) | \ V V / (_) | | | | (_| |_|_|
|_| |_|\___|_|_|\___/ \_/\_/ \___/|_| |_|\__,_(_|_)
Calling the figlet object as a function is shorthand for calling the text function. This method allows you to create ASCII Art from text. It takes in 3 parameters:
- Input Text - A string of text to turn into ASCII Art.
- Options - Either a string indicating the font name or an options object (description below).
- Callback - Optional function to execute with the generated ASCII Art.
The return value is a promise that resolves to the generated ASCII Art.
Example:
figlet.text(
"Boo!",
{
font: "Ghost",
horizontalLayout: "default",
verticalLayout: "default",
width: 80,
whitespaceBreak: true,
},
function (err, data) {
if (err) {
console.log("Something went wrong...");
console.dir(err);
return;
}
console.log(data);
}
);
That will print out:
.-. .-') ,---.
\ ( OO ) | |
;-----.\ .-'),-----. .-'),-----. | |
| .-. | ( OO' .-. '( OO' .-. '| |
| '-' /_)/ | | | |/ | | | || |
| .-. `. \_) | |\| |\_) | |\| || .'
| | \ | \ | | | | \ | | | |`--'
| '--' / `' '-' ' `' '-' '.--.
`------' `-----' `-----' '--'
Similarly, you can use Promise API:
try {
console.log(
await figlet.text("Boo!", {
font: "Ghost",
horizontalLayout: "default",
verticalLayout: "default",
width: 80,
whitespaceBreak: true,
})
);
} catch (err) {
console.log("Something went wrong...");
console.dir(err);
}
This will print the same output.
This method is the synchronous version of the method above.
- Input Text - A string of text to turn into ASCII Art.
- Font Options - Either a string indicating the font name or an options object (description below).
Example:
console.log(
figlet.textSync("Boo!", {
font: "Ghost",
horizontalLayout: "default",
verticalLayout: "default",
width: 80,
whitespaceBreak: true,
})
);
That will print out:
.-. .-') ,---.
\ ( OO ) | |
;-----.\ .-'),-----. .-'),-----. | |
| .-. | ( OO' .-. '( OO' .-. '| |
| '-' /_)/ | | | |/ | | | || |
| .-. `. \_) | |\| |\_) | |\| || .'
| | \ | \ | | | | \ | | | |`--'
| '--' / `' '-' ' `' '-' '.--.
`------' `-----' `-----' '--'
The options object has several parameters which you can set:
Type: String
Default value: 'Standard'
A string value that indicates the FIGlet font to use.
Type: String
Default value: 'default'
A string value that indicates the horizontal layout to use. 5 possible values for this: "default", "full", "fitted", "controlled smushing", and "universal smushing". "default" does the kerning the way the font designer intended, "full" uses full letter spacing, "fitted" moves the letters together until they almost touch, and "controlled smushing" and "universal smushing" are common FIGlet kerning setups.
Type: String
Default value: 'default'
A string value that indicates the vertical layout to use. 5 possible values for this: "default", "full", "fitted", "controlled smushing", and "universal smushing". "default" does the kerning the way the font designer intended, "full" uses full letter spacing, "fitted" moves the letters together until they almost touch, and "controlled smushing" and "universal smushing" are common FIGlet kerning setups.
Type: Number
Default value: undefined
This option allows you to limit the width of the output. For example, if you want your output to be a max of 80 characters wide, you would set this option to 80. Example
Type: Boolean
Default value: false
This option works in conjunction with "width". If this option is set to true, then the library will attempt to break text up on whitespace when limiting the width. Example
The 2 layout options allow you to override a font's default "kerning". Below you can see how this effects the text. The string "Kerning" was printed using the "Standard" font with horizontal layouts of "default", "fitted" and then "full".
_ __ _
| |/ /___ _ __ _ __ (_)_ __ __ _
| ' // _ \ '__| '_ \| | '_ \ / _` |
| . \ __/ | | | | | | | | | (_| |
|_|\_\___|_| |_| |_|_|_| |_|\__, |
|___/
_ __ _
| |/ / ___ _ __ _ __ (_) _ __ __ _
| ' / / _ \| '__|| '_ \ | || '_ \ / _` |
| . \| __/| | | | | || || | | || (_| |
|_|\_\\___||_| |_| |_||_||_| |_| \__, |
|___/
_ __ _
| |/ / ___ _ __ _ __ (_) _ __ __ _
| ' / / _ \ | '__| | '_ \ | | | '_ \ / _` |
| . \ | __/ | | | | | | | | | | | | | (_| |
|_|\_\ \___| |_| |_| |_| |_| |_| |_| \__, |
|___/
In most cases you'll either use the default setting or the "fitted" setting. Most fonts don't support vertical kerning, but a hand full of them do (like the "Standard" font).
The metadata function allows you to retrieve a font's default options and header comment. Example usage:
figlet.metadata("Standard", function (err, options, headerComment) {
if (err) {
console.log("something went wrong...");
console.dir(err);
return;
}
console.dir(options);
console.log(headerComment);
});
The function also return a promise that return an array with two values:
try {
const [options, headerComment] = await figlet.metadata("Standard");
console.dir(options);
console.log(headerComment);
} catch (err) {
console.log("something went wrong...");
console.dir(err);
}
The fonts function allows you to get a list of all of the available fonts. Example usage:
figlet.fonts(function (err, fonts) {
if (err) {
console.log("something went wrong...");
console.dir(err);
return;
}
console.dir(fonts);
});
For Node, it will look in the fonts folder and list all of the fonts there - this folder is configurable in case you want to use your own folder (see the defaults
method).
When dealing with this code in the browser, it will return a list of all of the fonts that come with this library. If you only want a list of the fonts that have been loaded into memory (ie, fetched and parsed and currently usable), use the loadedFonts
method (this also returns a list of strings).
The synchronous version of the fonts method
console.log(figlet.fontsSync());
As with fonts
, when used in the browser this will list all of the fonts that come with this library.
When you call loadFont
or parseFont
, the font information gets processed and put into an internal array. This method allows you to see all of the fonts that have been loaded. It returns an array of font names.
Resets the internal state so that no fonts have been loaded.
Allows you to use a font from another source.
const fs = require("fs");
const path = require("path");
let data = fs.readFileSync(path.join(__dirname, "myfont.flf"), "utf8");
figlet.parseFont("myfont", data);
console.log(figlet.textSync("myfont!", "myfont"));
Allows you to set a handful of default values for the library. Ex:
figlet.defaults({
font: "Standard", // default font
fontPath: "some-random-place/fonts", // default font path location
fetchFontIfMissing: true, // for the browser, fetch a font if its missing
})
Here's the basic ES module usage:
import figlet from "figlet";
import standard from "figlet/fonts/Standard";
figlet.parseFont("Standard", standard);
async function doStuff() {
const text = figlet.text("test", { font: "Standard" });
console.log(text);
}
doStuff();
In previous versions you imported js files from an importable-fonts folder. This still works, but the new way is slightly cleaner.
If you attempt to access a font that doesn't exist, the library will attempt to fetch it. You can control the fetch location via the fontPath
property in defaults
. If you want to disable this behavior (fetching a font if it doesn't exist), set fetchFontIfMissing
to false (with the defaults
method).
The browser API supports synchronous mode as long as the fonts have been loaded or preloaded.
Example:
figlet.defaults({ fontPath: "assets/fonts" });
figlet.preloadFonts(["Standard", "Ghost"], ready);
function ready() {
console.log(figlet.textSync("ASCII"));
console.log(figlet.textSync("Art", "Ghost"));
}
That will print out:
_ ____ ____ ___ ___
/ \ / ___| / ___||_ _||_ _|
/ _ \ \___ \ | | | | | |
/ ___ \ ___) || |___ | | | |
/_/ \_\|____/ \____||___||___|
('-. _ .-') .-') _
( OO ).-.( \( -O ) ( OO) )
/ . --. / ,------. / '._
| \-. \ | /`. '|'--...__)
.-'-' | | | / | |'--. .--'
\| |_.' | | |_.' | | |
| .-. | | . '.' | |
| | | | | |\ \ | |
`--' `--' `--' '--' `--'
See the examples folder for a more robust front-end example.
To use figlet.js on the command line, install globally:
npm install -g figlet
And then you should be able run from the command line. Example:
figlet -f "Dancing Font" "Hi"
Thanks goes to these people: (emoji key)
- 2025.09.07 v1.9.0 TypeScript refactor. Added Toilet fonts.
- 2025.07.11 v1.8.2 Added Terrace and Wavescape fonts. Fixed tag validation (https://github.com/patorjk/figlet.js/pull/134) thanks to @deverac
- 2025.04.11 v1.8.1 Added miniwi font.
- 2024.10.08 v1.8.0 Added support for promises for loadFont, preloadedFonts, and metadata methods. 5 fonts added: DiamFont, RubiFont, CosMike2, BlurVision ASCII, and Shaded Blocky.
- 2023.10.01 v1.7.0 Added support for promises for text method.
- 2023.04.08 v1.6.0 Added npx support (ex: npx figlet test).
- 2021.08.11 v1.5.2 Minor bug fixes.
- 2020.07.12 v1.5.1 Fixed with vertical smushing, updated lodash version.
- 2020.07.12 v1.5.0 Added width and whitespaceBreak options.
- 2020.04.26 v1.4.0 Removed jQuery from preloader and examples.
- 2020.02.23 v1.3.0 Added the "ANSI Regular" font and updated the README with info on how to use with Webpack.
- 2018.03.26 v1.2.1 parseFont works in node for adding fonts manually
- 2016.09.27 v1.2.0 jQuery replaced with fetch API / polyfill.
- 2016.04.28 v1.1.2 textSync now works in the browser with font pre-loading.
- 2014.08.15 v1.1.0 Sync functions added.
- 2014.07.31 v1.0.1 Bug fixes.
- 2013.12.28 v1.0.7 README update and minor tweaks.
- 2013.01.02 v1.0.8 Added tests and command line info.