JSX Minifier - Minify React JSX Code
Loading JSX Minifier...
How to Minify JSX/React Code - Step by Step Guide
Input Your JSX/React Code
Let's get your JSX code into the minifier! Whether you're optimizing React components for production, reducing bundle size, or preparing code for deployment, you have several convenient options:
Example: Unminified JSX Input
Here's what typical, readable JSX code looks like:
import React, { useState } from 'react';
// User card component
const UserCard = ({ user }) => {
return (
<div className="card">
<h2>{user.name}</h2>
<p>{user.email}</p>
</div>
);
};Automatic Minification
A moment after you stop typing, the code is parsed with Babel's JSX parser and printed back in compact form. Nothing is rewritten by search-and-replace, which is how hand-rolled minifiers end up cutting "https://" strings in half:
Example: Minified Output
The same code after minifying. It is a short component with one comment, so it shrinks by about a third:
import React,{useState}from'react';const UserCard=({user})=>{return<div className="card"><h2>{user.name}</h2><p>{user.email}</p></div>;};Download or Copy Result
The badge next to "Minified Output" and the panel under it show the size before and after. From there:
Example: Real-World Component Minification
A complete React component with hooks and comments:
import React, { useState, useEffect } from 'react';
// Product card component
const ProductCard = ({ product }) => {
const [quantity, setQuantity] = useState(1);
useEffect(() => {
console.log('Product viewed:', product.id);
}, [product.id]);
return (
<div className="product-card">
<img src={product.image} alt={product.name} />
<h3>{product.name}</h3>
<p className="price">${product.price}</p>
<button onClick={() => setQuantity(quantity + 1)}>
Add to Cart ({quantity})
</button>
</div>
);
};After minifying. Note that the text "Add to Cart ({quantity})" keeps its space, because React would show it:
import React,{useState,useEffect}from'react';const ProductCard=({product})=>{const[quantity,setQuantity]=useState(1);useEffect(()=>{console.log('Product viewed:',product.id);},[product.id]);return<div className="product-card"><img src={product.image}alt={product.name}/><h3>{product.name}</h3><p className="price">${product.price}</p><button onClick={()=>setQuantity(quantity+1)}>Add to Cart ({quantity})</button></div>;};Frequently Asked Questions
Why would I minify JSX by hand?
Usually to see how much of a component is comments and indentation, to paste a compact snippet into a CodePen, a bug report or a chat message with a length limit, or to inline a small widget into a page that has no build step. If your project already runs Vite, webpack, Next.js or Create React App, the production build minifies for you and does a lot more, so use this page for one-off jobs.
Will the minified JSX still work?
It should behave the same. The code is parsed with Babel's JSX parser first and printed back from that, so line breaks never get glued into a different statement, and strings, template literals, regexes and numbers are written exactly as you typed them (a long ID like 8901240544102066246 or a price like 14.50 keeps every digit). If the parser can't read your code, you get the line and column of the problem instead of a half-minified file.
What gets removed, and what stays?
Comments, indentation, line breaks and spaces around operators and brackets go. Whitespace inside JSX text is trimmed the way React reads it anyway: only where it touches a line break, so <p>Total: {count}</p> still shows Total: with its space. A few comments stay on purpose: /*! license banners, @license and @preserve, @jsx pragma comments (Preact and Emotion rely on them) and /// <reference> lines. Variable and function names are never shortened.
Can I paste TypeScript (TSX) here?
No, this page reads plain JavaScript with JSX, the kind that lives in .jsx and .js files. If you paste code with type annotations, interfaces or generics, it tells you so and points you to the TSX Minifier, which parses TypeScript.
How much smaller will my code get?
That depends on how much of the file is comments and formatting. The sample component on this page goes from 833 to 483 bytes, about 42% smaller. A tightly written component with few comments shrinks far less, because names are kept as they are. The badge above the output shows the exact figure for your code, and the panel under it lists the size before and after.
Is my code uploaded anywhere?
No. Parsing and minifying both happen in your browser, and nothing you paste or upload is sent to our server.
Related Tools
JSX Formatter
Format and beautify JSX/React code with proper indentation
JSX Fixer
Fix broken JSX automatically, repair React component syntax errors, unclosed tags, and invalid expressions
HTML to JSX Converter
Convert HTML to JSX/React format instantly
Markdown to JSX Converter
Convert Markdown to React JSX components for blogs and documentation
JSX Validator
Validate JSX syntax and React component structure
JSX to TSX Converter
Convert JSX to TypeScript TSX with type annotations
JSX to HTML Converter
Convert React JSX to standard HTML
JSX to JavaScript
Convert JSX to React.createElement calls