Input Code

Minified Code

Last updated

Code Minification Overview

Code minification removes unnecessary characters from source code — whitespace, comments, and long variable names — without changing functionality. The result is smaller files that load faster. Minification is a standard step in web build pipelines for JavaScript, CSS, and HTML.

Minification by Language

LanguageToolTypical Reduction
JavaScriptTerser, esbuild, UglifyJS40–70%
CSScssnano, clean-css, Lightning CSS20–40%
HTMLhtml-minifier-terser10–30%
JSONJSON.stringify (no indent)10–20%
SVGSVGO50–80%

JavaScript Minification with Terser

JavaScript
import { minify } from 'terser';

const code = `
  // Calculate factorial recursively
  function factorial(n) {
    if (n <= 1) return 1;
    return n * factorial(n - 1);
  }
  console.log(factorial(10));
`;

const result = await minify(code, {
  compress: {
    dead_code: true,
    drop_console: false,
    passes: 2
  },
  mangle: {
    toplevel: true
  },
  format: {
    comments: false
  }
});

console.log(result.code);
// → function n(r){return r<=1?1:r*n(r-1)}console.log(n(10));

Frequently Asked Questions

Yes, our Code Minifier is completely free with no registration required. Use it unlimited times without any restrictions.

Yes, all processing happens locally in your browser. Your data never leaves your device and is not stored on our servers.

No installation needed. The tool works directly in your web browser on any device.

Enter your input, click the action button, and get instant results. Copy the output for use in your projects.