Random Password Generator in JavaScript with Source Code

The Random Password Generator in JavaScript is web-based project which allows user to generate a random password on web using different browsers such as (Google Chrome, Brave, and Mozilla Firefox).

In addition, this Random Password Generator is developed using HTML, CSS, and JavaScript (JS).

A JavaScript is a scripting language that enables you to create dynamically updating content, control multimedia, animate images, and pretty much everything else, can update and change both HTML and CSS.

What is Random Password Generator in JavaScript

In JavaScript, Random Password Generator is a project which provide a random password this is complete and totally error free project.

In addition, once this project can generate a random password it provides a strong password, random characters, random number, and letter or number into a lowercase or uppercase letters you can easily copy the password in an input box of the project and hit the copy button.

Lastly, you can choose the length of the password you want to generate and can input the type of number ID (Identification) and type the checkbox ID symbols.

Why we need to Generate Random Passwords

This Random Password Generator in JavaScript (JS) is needed because it can provide a defense against unauthorized person who will accessed your websites or computer and confidential information that should need to hide safely.

Furthermore, this Password Generator in JavaScript can create a password which is really strong enough to protect your confidential files and information from a malicious programs or hackers.

This can project can produce a maintainable passwords which can help you a lot.

Benefits of Randomized Passwords

The main benefits of Random Password Generator in JavaScript is making sure that all the users are can generate a strong and easy password to remember.

In addition, this randomized password can be used for social media accounts and emails accounts. This project can protect also if you have a websites or any applications which has been developed and you want it to be more protected.

This Random Password Generator in JavaScript also includes a downloadable Source Code for free, just find the downloadable source code below and click to start downloading.

Talking about the highlights of this Random Password Generator, At the point when you click on the Generate secret key catch, at that point you will see various passwords at each click.

This system in JavaScript is undertaking to secret phrase aimlessly. Additionally, you can type the quantities of characters you need to remember for the secret word.

Anyway if you want level up your knowledge in programming especially C/C++ Programming Language, try this new article I’ve made for you Best C Projects with Source Code for Beginners Free Download 2020.

I have here a suggested list of Best JavaScript Projects with Source Code Free to download and I’m sure this can help you to improve your skills in JavaScript programming and web development as a whole.

To start creating a Random Password Generator, make sure that you have any platform in creating a JavaScript, bootstrap, and HTML installed in your computer, in my case I will use Sublime Text.

Project details and technology:

Project Name :Random Password Generator in JavaScript
Project Platform :JavaScript
Programming Language Used:JavaScript, HTML, and CSS
Developer Name :itsourcecode.com
IDE Tool (Recommended):Sublime
Project Type :Web Application
Upload Date:9/24/2022

Steps on how to create a Random Password Generator in JavaScript with Source Code

Time needed: 5 minutes

Random Password Generator in JavaScript with Source Code

  • Step 1: Open Sublime Text.

    First after installing sublime text IDE, click “open” to start.Open Sublime for Random Password Generator in with Source Code

  • Step 2: Create a HTML file.

    Second click “file” and select “save as” and named it “index.htmlwrite css Random Password Generator in JavaScript with Source Code

  • Step 3: Create a JavaScript file.

    Third click “file” and select “save as” and named it “passGeneratorScript.js

  • Step 3: Create a CSS file.

    Third click “file” and select “save as” and named it “generatePasswordStyle.cssWrite style css Random Password Generator in JavaScript with Source Code

  • Step 4: The actual code.

    You are free to copy the code given below and paste to your different file created.

This code is for the index.html

In the code given below, which is for the code for html file system and this code contains the interface of the application.(Random Password Generator)

<!-- Bootstrap CSS -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" integrity="sha384-JcKb8q3iqJ61gNV9KGb8thSsNjpSL0n8PARn9HuZOnIxN0hoP+VmmDGMN5t9UJ0Z" crossorigin="anonymous">
<title>Random Password Generator</title>
<link rel="stylesheet" href="css/generatePasswordStyle.css">
<div class="container">
    <form action="" name="passGen">
        <div class="col-xs-12">
            <input type="text" size="18" name="output" class="out" disabled>
            <input type="button" value="Generate Password" class="btn btn-success btn-block myBtn" onclick="populateForm(this.form.length.value)">
            <div class="col-xs-10">
                <strong class="passwords">Password Length: </strong>
            <div class="col-xs-2">
                <input type="text" name="length" size="3" value="6" class="inpt">
<script src="js/passGeneratorScript.js"></script>
<!-- Optional JavaScript -->
<!-- jQuery first, then Popper.js, then Bootstrap JS -->
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js" integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/umd/popper.min.js" integrity="sha384-9/reFTGAW83EW2RDu2S0VKaIzap3H66lZH81PoYlFhbGU+6BZp6G7niu735Sk7lN" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js" integrity="sha384-B4gt1jrGC7Jh4AgTPSdUtOBvfO8shuf57BaghqFfPlYxofvL8/KUEfYiJOMMV+rV" crossorigin="anonymous"></script>

This code is for the generatePasswordStyle.css

In the code given below, which is for the code for the CSS of the system.(Random Password Generator)

body {
background: -webkit-gradient(radial, center center, 0, center center, 460, from(#000000), to(#ffdb4d));
/* Safari 5.1+, Chrome 10+ */
background: -webkit-radial-gradient(circle, #000000, #000000);
/* Firefox 3.6+ */
background: -moz-radial-gradient(circle, #000000, #000000);
/* IE 10 */
background: -ms-radial-gradient(circle, #000000, #000000);
height: 600px;
.container {
width: 600px;
margin: 0 auto;
margin-top: 100px;
font-size: 3em;
.out {
margin-bottom: 10px;
width: 100%;
text-align: center;
color: #ff0000;
.myBtn {
padding: 20px 20px;
font-size: 40px;
margin-bottom: 20px;
.myBtn:hover {
background-color: rgb(0, 0, 255);
.passwords {
width: 400px;
font-size: 30px;
float: left;
color: #ffff;
margin-left: 0;
padding: 20.5px 24px;
background-color: #ffa500;
.inpt {
margin: 0;
padding: 5px 16.5px;
float: right;
text-align: center;
background-color: #000000;
color: #ff0000;

This code is for the passGeneratorScript.js

In the code given below, which is for the code for JavaScript file system.(Random Password Generator in JavaScript)

var keylisting = "abcdefghijklmnopqrstuvwxyz1234567890!@#$%&*/\?";
var temporary = "";
function generatePass(passwordLength) {
temporary = "";
for (var i = 0; i < passwordLength; i++) {
temporary += keylisting.charAt(Math.floor(Math.random() * keylisting.length))
return temporary;
function populateForm(enterLength) {
document.passGen.output.value = generatePass(enterLength);

Downloadable Source Code


In summary, this Random Password Generator in JavaScript can be useful to students or professional who wants to learn web development using technologies like HTML, CSS and JavaScript.

This project can also be modified to fit your personal requirements. Hope this project will help you to improve your skills. Happy coding!

That’s how you create Random Password Generator in your projects. You can always expand and try different ways in implementing the Random Password Generator in JavaScript in your JavaScript projects.

In this Mini Project for Random Password Generator is free to download and It is easy to understand and manipulate this project and use for education purpose only.


If you have any questions or suggestions about Random Password Generator in JavaScript, please feel free to leave a comment below.

1 thought on “Random Password Generator in JavaScript with Source Code”

Leave a Comment