How to Create a Word Counter in JavaScript (Free Code)

How to Create a Word Counter in JavaScript

Many times word count needs to be done between different projects. In all these cases, this type of JavaScript Word Counter will help you completely. In this tutorial, you will learn how to create Word Counter JavaScript

A lot of times we show character limits or word limits in different input boxes. For example, in the case of Twitter, there is a character limit.

Although I have shared a tutorial before where I have shown how to create a character limit input box. This tutorial will show you how to count words and characters. That means you will see both a project word and a character.

Word Counter JavaScript

Below is a preview that will help you to know how this Word Counter javascript works. Below you will find the required source code. 

To create this JavaScript Word Counter project I first created an input box using HTML and created a display. The input box is created using Textarea. 

Then I designed using CSS. After all, I have implemented this project (word counter HTML code) with the help of JavaScript.

See the Pen
by Foolish Developer (@foolishdevweb)
on CodePen.

As you can see above, I used the background-color blue of a webpage. I made a box on top of it. At the top of the box is a display. This display is divided into two parts. 

In the first part, you can see the information of Word Counter. In the second part, the information of the character counter can be seen. These values ​​will change when I change something in the input box. 

How to Make a Word Counter in JavaScript

This JavaScript Word Counter is very easy to make. I created it with some amount of HTML and some amount of CSS. A little bit of JavaScript has been used to make this counter project work.

The background of this input area is white and the text color is black. A shadow has been used around the box to create a beautiful banner that will further highlight this Word Counter in JavaScript on the webpage.

1. Basic structure of Word Counter

The basic structure of this word counter has been created using the following code. The background color of the webpage is blue.

<div class=”wrapper”>
* {
 padding: 0;
 margin: 0;
 box-sizing: border-box;
 font-family: “Poppins”, sans-serif;
body {
 background-color: #8bc1f7;
.wrapper {
 position: absolute;
 width: 75vmin;
 transform: translate(-50%, -50%);
 top: 50%;
 left: 50%;
Basic structure of Word Counter

2. Word Counter Result Box (more…)

Continue ReadingHow to Create a Word Counter in JavaScript (Free Code)

How to Make a Word Counter with JavaScript ‍

You will learn how to create word counters with the help of JavaScript. You will see that there are many websites on the internet that are much more popular for counting words or characters. I will try to explain in this tutorial a basic structure of how these designs work. 

A simple word counter depending on the general JavaScript programming code. First of all, I have made a box (Textarea) here. When you write something in that box, every character you write in that box will be a live count. The counted results can be seen in the box below. 

Simple Word Counter with JavaScript ‍

Basically, this design will count the number of characters, each character you write in this box will count with space. I used a small amount of HTML and CSS code to create the box and design the background. 

Here all the work is handled by JavaScript, that is, everything shown in the box that counts these words is handled by JavaScript. If you want to know better how this word (character) counter works then you can see the demo below.

See the Pen
word counter
by Foolish Developer (@fghty)
on CodePen.

As you can see, I made a rectangular box here. When you type something in that box, it will count live. The counted results can be seen through a small box below.

In the background of this box, I have used white color and added a blue border all around to enhance the beauty. Follow the tutorial below to make this design. In this case, first of all, let me say that I have used the bootstrap CDN link. Be sure to add a link to these two in the head section of your HTML file.

Step 1: Design the background of the word counter

 First of all, you create HTML and CSS files. Then copy the following HTML structure and add it to your HTML file.

<!DOCTYPE html>
<html lang=”en”>
  <link rel=”stylesheet” href=””>
  <meta charset=”UTF-8″>
  <meta http-equiv=”X-UA-Compatible” content=”IE=edge”>
  <meta name=”viewport” content=”width=device-width, initial-scale=1.0″>
   /* CSS Code */
  <div class=”column”>
  // Javascript code

Using the CSS code below I basically designed this word counter in the background.


Continue ReadingHow to Make a Word Counter with JavaScript ‍