What is JSX minification?
JSX minification removes unnecessary characters from React component source — comments, runs of whitespace between tags, blank lines, leading and trailing space inside expression containers — without changing the rendered output. It is the JSX equivalent of JavaScript minification, but it must be tag-aware so it does not collapse whitespace that would be visible to the user (text content between tags), and it must not alter strings or template literals.
When should I minify JSX manually?
In production builds you almost never minify JSX directly — you let your bundler (Webpack, Vite, esbuild, SWC) compile JSX to React.createElement calls and minify the resulting JavaScript. Manual JSX minification is useful for: shrinking inline JSX in markdown blog posts, fitting a component into a tight code-sample widget, generating compact JSX for an email template generator, or producing a one-line repro for a bug report.
Is whitespace between JSX tags ever significant?
Yes — whitespace inside text content rendered between two adjacent inline tags collapses to a single space and IS visible. The minifier preserves this: it only collapses whitespace that sits directly between a closing > and an opening <, never inside a text node. JSX-text whitespace rules are documented in the React docs and the babel-plugin-transform-react-jsx-source spec.
Does the minifier change runtime behaviour?
No. JSX outside string and template-literal contexts is whitespace-insensitive at the token level. The minifier removes whitespace and comments without touching identifiers, attribute values, or string literals — the AST your bundler parses is identical to the original. To verify, render before and after through the same Babel/SWC config; the emitted JavaScript should match.
What does the drop-trailing-semicolons option do?
Inside an expression container — for example {const x = compute(); x * 2;} (an IIFE-style expression) — the final semicolon before } is unnecessary in many JS engines and frameworks because automatic semicolon insertion handles it. Removing it shaves a few bytes per container. Disable the option if your codebase requires explicit terminators.
Will it remove JSX comments {/* … */}?
Yes when the strip-comments option is enabled. JSX comments are JS block comments inside an expression container, so the minifier sees them as both an expression container and a /* … */ block. Both are removed. // line comments inside expression containers are also removed. String contents that look like comments (e.g. const x = "// not a comment") are protected because strings are tokenised first.
Is my JSX uploaded to your servers?
No. Minification runs entirely in JavaScript inside your browser. Components containing API keys, proprietary algorithms, or unreleased features never leave the device. You can verify this in DevTools → Network — no requests are made when you click Minify.
How is this different from running a bundler?
A bundler does much more — it resolves imports, transforms JSX to React.createElement, applies Babel plugins, tree-shakes, and emits JavaScript that is then minified with terser or esbuild. This tool only does the JSX whitespace-and-comment pass. Use it for snippets, not for production builds.