Skip to content

Developer tools

Code Minifier

Code Minifier shrinks JavaScript, CSS, HTML, and JSON by removing unnecessary characters. It's useful when you want smaller assets or quick minified output for testing and delivery.

01 / How it works

Simple steps, fast result.

  1. 01

    Paste code or open a file.

  2. 02

    Select the language or let the tool detect it.

  3. 03

    Minify the code and copy or download the result.

02 / Features

What you get.

Multiple languages

Minify JavaScript, CSS, HTML, and JSON in the same tool.

Before/after clarity

See the original and minified output so you know what changed.

Quick copy/download

Grab the result for deployment, testing, or sharing.

Runs in browser

Code is processed locally on your device.

03 / Guide

Using Code Minifier, in depth.

Code Minifier makes JavaScript, CSS, HTML and JSON files smaller by removing everything a browser doesn't need to run them. This guide explains what gets removed in each language, what each option does, when a build tool is the better choice, and how to check the output before it goes live.

What minification removes

Code is written for people: indentation, line breaks, comments, long descriptive names. Browsers don't need any of that. Minification strips it out and rewrites what's left in the shortest form that behaves the same way. Smaller files download faster, which matters most on mobile data and slow connections.

After each run the tool shows the original size, the minified size, the percentage saved, and the size of both versions when gzipped. The gzipped figure is the useful one, because most web servers compress files before sending them. Minified code still shrinks further with gzip, but the gap between the original and the minified version is smaller than the raw numbers suggest.

Each language, and its options

  • JavaScript uses Terser, the same minifier many build tools use. It removes whitespace and comments, rewrites expressions more compactly, and drops code that can never run. Shorten names renames local variables to one or two letters, usually the biggest saving. Remove console.* deletes console.log and similar calls. ES module treats the file as a module, which allows import and export and some extra optimisations; turn it off for old-style scripts. Keep license comments preserves comments marked @license, @preserve or starting with /*!.
  • CSS uses CSSO. Beyond removing whitespace and comments, Merge rules combines duplicate selectors and repeated declarations into fewer rules. License comments in the /*! ... */ form can be kept.
  • HTML collapses whitespace between tags, removes comments, drops attributes that are already the default (such as type="text/javascript"), shortens boolean attributes like disabled="disabled" to just disabled, and can minify CSS and JavaScript inside <style> and <script> tags.
  • JSON removes every space and line break. If the JSON isn't valid, you'll get an error instead. The Dev Formatter explains JSON errors in more detail and can format the result back for reading.

Using the minifier

  1. 01Choose the language at the top.
  2. 02Paste your code, or open a file (.js, .mjs, .css, .html or .json).
  3. 03Adjust the options if you need to. The output updates as you go.
  4. 04Copy the result or download it as a file.

If the code has a syntax error, the output panel shows the error message and the line and column where it happened. Minifiers have to parse your code fully, so they're stricter than a quick glance; fix the error at that location and the output appears.

When to use a build tool instead

This tool is ideal for one-off jobs: a script for a WordPress theme, a snippet for a landing page, a widget you're embedding, a JSON config you need to make smaller, or checking how much a file would shrink. For an ongoing project, a build tool such as Vite, esbuild, webpack or Parcel is better. Those tools minify every time you build, bundle many files into a few, and remove unused code across modules.

There's also the question of debugging. Minified code is hard to read in an error message: everything is on one line and the names are meaningless. Build tools solve this with source maps, separate files that let the browser's developer tools show the original code. This minifier doesn't produce source maps, so keep your original files, and deploy minified code only once it's tested.

Checking the output before you deploy

  • Test it in a browser. Load the page with the minified file and click through the features that use it. Check the browser console for errors.
  • Watch for global names. Shorten names only renames local variables, so code that other scripts call by name keeps working. But if your code looks up its own variables by name at runtime, for example with eval, renaming can break it. Turn the option off if that applies.
  • Removing console calls. Make sure no logic depends on a console call, for example a function called inside console.log(...) for its side effects.
  • HTML whitespace. Collapsing whitespace can remove a space between two inline elements, such as two links side by side. Check spacing in places like menus and buttons.
  • Keep the source. Never edit the minified file. Make changes in the original and minify again.

Minifying is not protecting

Minified code looks unreadable, but any browser's developer tools can reformat it with one click, and the logic is still all there. If you want to make copying harder, the JavaScript Obfuscator goes further, with real costs in size and speed that its guide explains.

Everything runs in your browser, in a background worker so the page stays responsive. Your code isn't uploaded anywhere.

04 / FAQ

Common questions.

What languages does it support?

JavaScript, CSS, HTML, and JSON.

Is minifying the same as obfuscating?

No. Minifying makes code smaller. Obfuscation makes JavaScript harder to read; use the JavaScript Obfuscator for that.

Is my code uploaded?

No. Minification runs in your browser.