Code Minifier

Paste code, pick its language (JavaScript, CSS, HTML, or JSON), and get back a minified version, using the same minifiers as this site's dedicated per-language minifiers. A free online tool from Staaarter, right in your browser.

Runs locallyUpdated 2026-07-24

Overview

Introduction

Switching between separate minifier pages for different languages is friction when you're working across several file types.

This tool combines JavaScript, CSS, HTML, and JSON minification behind one language switcher, entirely in your browser.

What Is Code Minifier?

A single interface over this site's existing minifiers: Terser for JavaScript, csso for CSS, html-minifier-terser for HTML, and JSON.stringify for JSON.

Selecting a language routes your input to the matching minifier; the underlying behavior is identical to the dedicated tool for that language.

How Code Minifier Works

Your input is passed to the minifier matching the selected language, and the result (or any syntax error) is shown the same way the dedicated tool would show it.

Switching the language selector doesn't transform your existing input, it just changes which minifier the next run uses, so re-check your pasted code is valid for the newly selected language before minifying again.

When To Use Code Minifier

Use it when you want one bookmarked tool for occasional minification across a few different languages rather than switching pages.

It's also handy for pasting a snippet from documentation or a chat conversation when you're not yet sure which language tool you'll need next.

Features

Advantages

  • Runs entirely client-side.
  • One interface instead of remembering separate URLs per language.
  • Makes it easy to compare how differently each language's minifier behaves on similar input, since switching languages doesn't lose your place.

Limitations

  • For frequent single-language use, the dedicated JavaScript/CSS/HTML minifier pages have language-specific options this generic tool doesn't expose.

Examples

Minifying JSON

Input

{"id": 1, "name": "Ada"}

Output

{"id":1,"name":"Ada"}

With JSON selected, the input is parsed and re-serialized without whitespace.

Best Practices & Notes

Best Practices

  • Double-check the language selector matches your input before relying on the result.
  • Use the JSON option only for whitespace removal; it won't restructure or shorten values the way csso restructures CSS rules.

Developer Notes

Dispatches to `minifyJavaScript`, `minifyCss`, `minifyHtml`, or a direct `JSON.stringify` round-trip based on the selected language, reusing the same lib functions as the dedicated per-language tools.

Code Minifier Use Cases

  • Minifying a few different file types without navigating between separate tool pages
  • Quickly testing how a snippet minifies before deciding which dedicated tool to bookmark

Common Mistakes

  • Leaving the language selector on the wrong language and getting a confusing syntax error.
  • Pasting TypeScript and expecting the JavaScript option to strip types; only plain JavaScript syntax is supported.

Tips

  • For CSS or HTML, the dedicated minifier pages show the same result with a bit more file-type-specific framing.
  • If you only ever minify one language, the dedicated tool for that language saves a click since this one defaults to JavaScript.

References

Frequently Asked Questions