Back to HomeWeConvertFiles Guide

Code Minifier and Beautifier for HTML, CSS, and JavaScript

HTML / CSS / JS

Source code is written for people, with indentation, descriptive names, comments, and spacing; production assets are delivered to machines, where many of those characters add transfer size without changing behavior. The Code Minifier & Beautifier supports HTML, CSS, and JavaScript: choose a language and action, paste code, and process it in the browser. It reports UTF-8 input and output byte sizes, shows the percentage change, lets you copy the result, and downloads output.html, output.css, or output.js according to the selected language.

Minify or beautify code

Quick answer. Select HTML, CSS, or JavaScript; choose Minify; paste the source; and run the tool. Review the output and size statistics, then test the transformed code before deploying it. For readable formatting instead, choose Beautify, which uses two-space indentation and may increase the byte count. Keep the original source and treat minified files as generated build artifacts.

What minification and beautification do

Minification rewrites source code into a smaller representation. Depending on the language and engine, it can remove unnecessary whitespace and comments, shorten or restructure expressions, combine compatible CSS rules, shorten JavaScript variable names, and eliminate redundant JavaScript. Readable JavaScript such as:

function calculateSubtotal(items) {
  return items.reduce((total, item) => {
    return total + item.price * item.quantity;
  }, 0);
}

can become a compact single-line representation similar to:

function calculateSubtotal(t){return t.reduce((t,c)=>t+c.price*c.quantity,0)}

Beautification does the reverse presentation task, adding consistent whitespace and indentation to compressed or poorly formatted code for review, debugging, and understanding third-party snippets. It does not reconstruct original comments, variable names, or author intent — information removed during minification generally cannot be recovered from the minified file.

How to use the Code Minifier & Beautifier

  1. 1. Choose HTML, CSS, or JavaScript. The default language is HTML.
  2. 2. Select Minify or Beautify. The default mode is Minify.
  3. 3. Paste the code into the input panel.
  4. 4. Run the action and review the output and byte statistics.
  5. 5. Copy the output or download the generated output.* file.
  6. 6. Compare, lint, build, and test it in the target project.

Changing the language determines both the processing engine and the downloaded file extension. Clear removes the input, output, messages, and current statistics.

JavaScript minification with Terser

JavaScript minification uses Terser. Its default process can do more than remove spaces: it can compress expressions and mangle eligible names. That often produces better savings, but it is also why transformed JavaScript needs meaningful tests. The output may shorten local identifiers and rewrite syntax while preserving intended behavior, so do not rely on exact minified variable names. Code that uses string-based name lookup, reflection, direct eval, unusual build-time macros, or undocumented framework conventions can be sensitive to mangling or compression.

The tool returns processed code only; it does not generate a source map. Without one, production stack traces refer to the minified file's lines and columns, making debugging harder. A pasted fragment also lacks the context of imports, exports, target-browser configuration, TypeScript compilation, JSX transformation, and bundler defines — this tool processes JavaScript text, it is not a full bundler or transpiler. Compile language extensions before minification and validate the result in the intended runtime.

CSS minification with CSSO

CSS minification uses CSSO, which can remove redundant syntax and optimize compatible structures in addition to deleting whitespace — for example, it may merge separate margin declarations into a shorter equivalent when it determines that is safe. Because CSS behavior depends on cascade order, specificity, custom properties, and browser support, test key pages and states after minification, including responsive breakpoints, hover and focus states, dark mode, printed output, and right-to-left layouts.

The tool does not run PostCSS, resolve imports, rewrite asset URLs, add vendor prefixes, or understand a framework's purge configuration, and it does not compile Sass, Less, or another preprocessor into CSS. Provide compiled CSS as input.

HTML minification behavior and limitations

HTML minification uses a lightweight built-in routine rather than a full HTML compiler. It removes HTML comments, collapses repeated spaces and tabs outside protected blocks, removes whitespace between tags, removes line indentation, and trims the result. Blocks matching pre, textarea, script, and style are protected from the whitespace pass. That design is fast, but HTML whitespace can be meaningful:

<span>First</span> <span>Second</span>

Removing the text space between the closing and opening tags can display FirstSecond, so always visually test inline content after HTML minification. The routine also removes HTML comments, which may drop conditional comments, template markers, build directives, or legal notices. Embedded <script> and <style> contents are preserved rather than independently minified — process those assets separately when needed.

Beautifying HTML, CSS, and JavaScript

Beautification uses language-specific js-beautify functions with a fixed two-space indentation setting: JavaScript is processed by the JavaScript beautifier, CSS by the CSS beautifier, and HTML by the HTML beautifier with its supporting language modules loaded as needed. For example, this dense CSS:

.card{display:grid;gap:1rem;padding:1.5rem}.card h2{margin:0;color:#172554}

can be reformatted as:

.card {
  display: grid;
  gap: 1rem;
  padding: 1.5rem;
}

.card h2 {
  margin: 0;
  color: #172554;
}

There are no controls for tabs, brace style, maximum line length, quote preference, or semicolons. Use the result as a readable baseline; if a repository enforces Prettier, ESLint, Stylelint, or another formatter, run the project's configured tooling before committing. Beautification is not syntax repair, and it is not deobfuscation: meaningful names and removed control structure cannot reliably be inferred.

Understanding the size statistics

After successful processing, the tool shows input size in bytes, output size in bytes, and the percentage change. The byte values are measured by creating browser Blob objects from the input and output, so they reflect the UTF-8 size of the displayed text, and Unicode characters may require more than one byte. For minification a reduction is shown with a minus sign; beautification usually increases size and can show a plus sign.

The percentage is calculated from the uncompressed input and output; it is not a measurement of Brotli or gzip transfer savings. A large raw reduction may become a smaller network improvement after HTTP compression because repeated whitespace already compresses well, so measure the actual built and compressed assets when optimizing production performance.

Minification vs. compression, bundling, and transpilation

ProcessMain jobTypical output
MinificationRewrite source into fewer bytesSmaller HTML, CSS, or JS text
Network compressionCompress bytes during transferBrotli- or gzip-encoded response
BundlingCombine and resolve modules/assetsOne or more application bundles
TranspilationConvert syntax for another targetBrowser-compatible JavaScript or CSS
Tree shakingRemove unused module exportsSmaller JavaScript bundle

A strong production pipeline may use several steps. This browser tool minifies or beautifies one pasted source string; it does not bundle modules, resolve dependencies, transpile TypeScript, or configure server compression.

Can minification break code?

It can. Mature minifiers aim to preserve semantics, but source code can depend on behavior that transformations expose: JavaScript may rely on function or variable names; HTML may rely on whitespace between inline elements; CSS may rely on ordering or unusual browser behavior; comments may contain licenses, directives, or conditional markup; template syntax may not be valid plain HTML, CSS, or JavaScript; and an incorrect language selection applies the wrong parser.

Keep source control and run automated tests. For JavaScript, test initialization, asynchronous flows, error handling, and production-only paths. For CSS and HTML, perform visual regression and accessibility checks at representative viewport sizes. Minifiers often remove comments, and some dependencies require license notices to remain in distributed assets — preserve required notices through a build-supported mechanism and verify the final artifact, not only the source repository.

Common processing errors

JavaScript cannot be parsed

Look for incomplete statements, TypeScript annotations, JSX, or an unmatched quote or bracket. Compile extensions before using the JavaScript minifier.

CSS output is unexpected

Confirm the input is compiled CSS rather than Sass or Less. Check custom syntax, malformed declarations, and cascade-sensitive rules.

HTML text loses spaces

Whitespace between tags is removed. Add required spacing inside text nodes, or avoid this lightweight HTML minification for whitespace-sensitive markup.

Template directives disappear or move

Comments and nonstandard template syntax may be treated as removable HTML or invalid language input. Use tooling designed for the template framework.

Beautified output is larger

That is expected. Beautification adds whitespace for readability; the statistics display the increase.

A processing library does not load

The language engines are lazy-loaded from version-pinned third-party CDN scripts. Network filters or script blockers can prevent an engine from loading. Retry in an allowed browser environment.

Privacy and code security

Processing occurs in the browser and the tool does not execute, evaluate, or render the pasted code. Required parsing libraries are loaded on demand from third-party content delivery infrastructure.

Source code can contain credentials, internal endpoints, customer identifiers, proprietary logic, and comments never intended for distribution. Remove secrets before pasting, follow organizational policy, and prefer representative snippets. Minification is not a secret-removal tool: string literals, URLs, API keys, and embedded configuration can remain readable in the output. Never assume minification protects intellectual property — it creates friction for humans but is reversible enough to inspect and beautify. Use proper access controls and secret management.

Frequently asked questions

Which languages are supported?

The tool supports HTML, CSS, and JavaScript input.

Does it execute my JavaScript or render my HTML?

No. It parses and rewrites code as text. It does not execute JavaScript or render the markup.

Can it beautify minified code?

Yes. Beautify adds two-space formatting, but it cannot restore removed comments, original names, or author structure.

Does JavaScript minification rename variables?

Terser's default minification can mangle eligible names and compress expressions. Test output and do not rely on minified local names.

Does it minify CSS inside HTML?

The lightweight HTML minifier preserves style and script blocks during whitespace processing; it does not independently run CSSO or Terser on their contents.

Does it generate source maps?

No. The output contains processed code only.

What do the size numbers mean?

They are the UTF-8 byte sizes of input and output plus the uncompressed percentage change, not gzip or Brotli savings.

What filenames are downloaded?

The tool downloads output.html, output.css, or output.js, based on the selected language.

Is minification the same as obfuscation?

No. Minification primarily reduces size. It may shorten names, but it does not provide dependable secrecy.

Can minified code be deployed without testing?

No automated transformation should bypass project tests and review. Validate behavior in the target environment first.

Related tools

Diff Checker

Compare readable source and processed output.

JSON Formatter

Format JSON rather than using the code minifier.

SQL Formatter

Format database queries with dialect options.

Related guides

QR Code Generator Guide

Generate high-quality custom QR Codes for any URL, text, or phone number instantly.

Word & Character Counter Guide

Live-updates word, character, and paragraph counts plus a reading-time estimate.

JSON Formatter / Validator Guide

Format, validate, beautify, and minify raw JSON string data dynamically.

Minify or beautify your code

Pick a language and action, paste HTML, CSS, or JavaScript, and copy or download output.html, output.css, or output.js.

Use Code Minifier