JavaScript Minifier - Minify JS Code Online

Minify and compress your JavaScript code instantly using our free online JS minifier. Improve website performance by reducing file size and optimizing your scripts.

Tags: compress code javascript minify code typescript

🚀 296,277 total conversions (107 this month)

Practice Python with coding challenges

Solve hands-on problems right in this editor: run the sample tests, submit, and get an AI code review.

All Python challenges
Easy

Rectangle Perimeter

Compute the perimeter of a rectangle from its sides.

You'll learn ArithmeticReturn values
BeginnerLearning-pathVariables
Easy

Distance Between Points

Compute the straight-line distance between two points.

You'll learn Pythagorean theoremSquare roots
BeginnerFunctionsLearning-pathmath
Easy

Average of Three

Average three whole numbers.

You'll learn ArithmeticDivision
BeginnerLearning-pathVariables
Easy

Dot Product of Two Vectors

Multiply two vectors element by element and add the results: the core operation of every neuron.

You'll learn VectorsDot product
Neural networksaimachine learning
Easy

Prime Number Check

Decide whether a number is prime.

You'll learn DivisibilityLoop optimization
BeginnerLoopsNumbersStudent-beginner
Easy

Celsius to Fahrenheit

Convert a temperature from Celsius to Fahrenheit.

You'll learn FormulasOperator precedence
BeginnerLearning-pathVariables
Easy

Count Uppercase Letters

Count the capital letters in a text.

You'll learn Character checksCounting
BeginnerLearning-pathStrings
Easy

Days in a Month

Return how many days a month has, including leap years.

You'll learn Calendar rulesHelper functions
BeginnerConditionsFunctionsLearning-path
Easy

Largest of Three

Pick the largest of three numbers without a built-in max.

You'll learn ComparisonsCombining conditions
BeginnerConditionsLearning-path
Easy

Letter Grade

Turn a test score into a letter grade.

You'll learn if/elif chainsRanges
BeginnerConditionsLearning-path
Easy

Halve Until One

Count how many halvings bring a number down to 1.

You'll learn While loopsCounting
BeginnerLearning-pathLoops
Easy

Absolute Value Without abs

Compute an absolute value with a condition.

You'll learn NegationNo built-ins
BeginnerConditionsLearning-path

Introduction

This online JavaScript minifier tool helps you compress and optimize your JavaScript code quickly and efficiently. It’s a great way to reduce file size, improve website performance, and streamline your scripts.

How to Use This Tool

  1. Paste your JavaScript code directly into the editor or type it in.
  2. Click the Minify button to compress your JavaScript code.
  3. After minifying, you can:
    • Download the optimized result.
    • Save or share it using a unique link.
    • Sign in with Google or GitHub to save your minified code for future use.

What is JavaScript?

JavaScript is a versatile programming language that allows developers to create dynamic and interactive features on web pages, such as animations, form validations, and real-time updates. It works alongside HTML and CSS to provide a complete user experience.

JavaScript is a core technology of the web and is widely used for both front-end and back-end development. It’s supported by all modern browsers and is essential for creating interactive and responsive websites and applications.

Learn more about JavaScript from the official JavaScript guide .

JavaScript Syntax

      
// program to solve quadratic equation
let root1, root2;

// take input from the user
let a = prompt("Enter the first number: ");
let b = prompt("Enter the second number: ");
let c = prompt("Enter the third number: ");

// calculate discriminant
let discriminant = b * b - 4 * a * c;

// condition for real and different roots
if (discriminant > 0) {
    root1 = (-b + Math.sqrt(discriminant)) / (2 * a);
    root2 = (-b - Math.sqrt(discriminant)) / (2 * a);

    // result
    console.log(`The roots of quadratic equation are ${root1} and ${root2}`);
}

// condition for real and equal roots
else if (discriminant == 0) {
    root1 = root2 = -b / (2 * a);

    // result
    console.log(`The roots of quadratic equation are ${root1} and ${root2}`);
}

// if roots are not real
else {
    let realPart = (-b / (2 * a)).toFixed(2);
    let imagPart = (Math.sqrt(-discriminant) / (2 * a)).toFixed(2);

    // result
    console.log(
    `The roots of quadratic equation are ${realPart} + ${imagPart}i and ${realPart} - ${imagPart}i`
  );
}
      
    

What is Minification?

Minification is the process of minimizing code and markup in your web pages and script files. It’s one of the main methods used to reduce load times and bandwidth usage on websites. Minification dramatically improves site speed and accessibility, directly translating into a better user experience. It’s also beneficial to users accessing your website through a limited data plan and who would like to save on their bandwidth usage while surfing the web.

Why minify JavaScript?

When creating JavaScript developers tend to use spacing, comments and well-named variables to make code and markup readable for themselves. It also helps others who might later work on the assets. While this is a plus in the development phase, it becomes a negative when it comes to serving your pages. Web servers and browsers can parse file content without comments and well-structured code, both of which create additional network traffic without providing any functional benefit.

To minify JavaScript files, comments and extra spaces need to be removed, as well as crunch variable names so as to minimize code and reduce file size. The minified file version provides the same functionality while reducing the bandwidth of network requests.

Examples

Before minified

      
// program to find the HCF or GCD of two integers

let hcf;
// take input
const number1 = prompt('Enter a first positive integer: ');
const number2 = prompt('Enter a second positive integer: ');

// looping from 1 to number1 and number2
for (let i = 1; i <= number1 && i <= number2; i++) {

    // check if is factor of both integers
    if( number1 % i == 0 && number2 % i == 0) {
        hcf = i;
    }
}

// display the hcf
console.log(`HCF of ${number1} and ${number2} is ${hcf}.`);
      
    

After minified

      
let hcf;const number1=prompt('Enter a first positive integer: ');const number2=prompt('Enter a second positive integer: ');for(let i=1;i<=number1&&i<=number2;i++){if(number1%i==0&&number2%i==0){hcf=i}}console.log(`HCF of ${number1} and ${number2} is ${hcf}.`);