August 15, 2022
Book Title Generator: A JavaScript Program with a Creative Lesson
One morning, I was staring at the screen a bit bored, trying to find something productive to do. Browsing through the blog, I saw an old post on how to select a title for your novel. I immediately had a flash of inspiration: What I should make is a book title generator!
The truth is, I wasn’t super serious about it, it was mostly meant as something productive to pass the time with. I mean, as I explain in the post linked above, picking a title for your novel cannot be a random process. More still, it cannot be a spur-of-the-moment thing, either. Conversely, it has to be a result of deliberation. It involves patience.
So, how does a book title generator fit in all that?
Honestly, I didn’t trouble myself with it. I just began coding – as I said, for the fun of it. But I was thoroughly surprised with the result, as it revealed to me several important things about creativity, including in terms of coming up with book titles. The book title generator… generated ideas.
In this post I’ll offer you all the details of my thought process behind making this JavaScript book title generator. I’ll also offer you the code and the program to try for free. However, above all, I’ll talk about the important lessons on creativity this silly little program had to offer.
A Book Title Generator in JavaScript: The Thought Process
As a very first thing, I realized I wanted the program to be simple – both in terms of coding, as well as in terms of using. I really didn’t intend this book title generator to be a serious program – nothing like Narrative Nods, for example. One reason was because, as I explained, coming up with titles isn’t something you can outsource to a program, if at least art matters to you.
So, I didn’t want to bother with AI/ML or anything of the sort. Instead, I focused on stuff I know well: linguistics, syntax structure, patterns.
Solid Structure, the First Step
As with the automatic text for Planet Generator, the first step was to come up with some basic ways to structure a book title. For example:
The man and the woman
A smart woman
The man who knew a woman
And so on, you get the idea. After I identified 7-8 basic such patterns and set up the structure, all I needed to do was come up with a way to feed it words relevant to the book genre which were mostly cohesive.
I mean, we can’t have a horror book with a title such as The Pink Truck and the Jolly Unicorn, rightOr… can we? That is part of the creative lesson of this whole process, as you’ll see below in the post.?
So, the first thing to do would be to have a vocabulary pertinent to the genre. The second thing, to have some sort of cohesion. In other words, The Dark Witch and the Haunted House is far preferable to The Unemployed Witch and the Manhattan Penthouse, right?
A Book Title Generator in JavaScript: Datamuse and RiTa
Once again, I used the absolutely excellent Datamuse API and RiTa library to get the results I wanted. I first came up with arrays of words for each genre. For instance:
var fantasyArray= ["supernatural", "ghost", "witch", "creature", "vampire", "werewolf", "elf", "magician", "amulet", "ring"];
var crimeArray = ["detective", "police", "murder", "suspect", "investigation", "crime", "criminal", "robbery", "embassy", "mystery", "spy", "secret"];
And so on, for each of the 7-8 different genres I included. The user selects genre, then the program picks a random word from the relevant array to send to Datamuse, retrieving a list of synonyms. For instance, sending “monster” gives you words like “demon”, “fiend”, “ogre”, etc.
The process continues, retrieving relevant adjectives and verbs. It’s not always accurate (indeed, sometimes there are hilariously “off” results), but considering the simplicity, it works very well. Here are some examples:
- The Good Fairies Of Dubrahe Meadows (fantasy)
- Earthlings Of Forfest Lake (science fiction)
- The Retro Fondness (literary fiction)
- Affection In The Meadows (romance)
Source Code and the Program
If you’re looking for the source code of this book title generator, feel free to grab it on GitHub. I’m sure you can improve it further if you play with it – it took me a few hours to code it, and I got bored after that.
And if you want to try it, there you go – note that the code is hosted on raw.githack. This means that, as a free service, 100% uptime cannot be guaranteed. If the program seems unresponsive, try again later.
Instead, I prefer to talk about something much more interesting: What this book title generator revealed to me in terms of creativity.
A Book Title Generator in JavaScript: Creative Lessons
After running the program (that is, after I’d polished it a bit), I realized something: It worked, in spite of itself!
In other words, the program – meant as a silly exercise, remember – was never meant to actually, really, provide proper titles. And yet it kind of worked – the titles were evocative, they felt somehow appropriate to the genre in question. I quickly realized what made the program work.
My imagination!
A phrase like “The Retro Fondness” doesn’t really say anything. It’s grammatical, but pretty ambiguous and empty-spaced. And that’s precisely why it works!
The Power of Creating Meaning
The reason this silly little book title generator works is because the user does most of the important work. We try to squeeze such open-ended titles into meaning. We try to visualize a story there. Above all, we do so subjectively.
In other words, “The Retro Fondness” will connote certain things (a certain story, in a way) to user A, but perhaps very different to user B.
Ultimately, the best part about this book title generator is that it allows the reader to figure things out on their own. You shouldn’t use this tool blindly, the way you wouldn’t outsource naming your character to a random name generator.
Maybe that’s what a great title should be to begin with!